INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Check GridView and play sound if result is zero!

Check GridView and play sound if result is zero!

(OP)
Hi,

I have an asp.net C# web site and in one of the pages I have a grid view that returns some results and fires a warning sound if the result = 0 (see below):

if (gvScnResults.Rows.Count == 0)
{
SoundPlayer PlaySound = new SoundPlayer("path_to_sound_file/Sounds/warning.wav");
PlaySound.Play();
}

The sound works great on local machine, but when it is on the remote web server, it will not play. I presume it is required to play in the client's browser / machine and despite many hours of looking and testing I'm coming up short!

Any pointers gratefully received.

Thanks.

RE: Check GridView and play sound if result is zero!

Yes, this will work on your local machine because it is also the "Server". Once you roll this code out to a server other than your local machine, that is where it runs. You will need to play the sound on the client, if possible.

Just poked around a bit and found this. Maybe it will work for you?:
http://stackoverflow.com/questions/10105063/how-to...

RE: Check GridView and play sound if result is zero!

(OP)
Hi, yes, the link you provided was similar to my problem. In the end, however, I solved it by thinking outside the box!

Briefly, I created two html files with html5 audio clips in them - one for 'on' and one 'off'. In the aspx page, I dropped in two iFrame tags at the bottom of the page. In the code behind, on the text changed event, I hide/show the relevant iFrame depending on the result returned from a query. It works both locally and remotely and is instantaneous.

It's probably a horrid way to do it, but it's the only way that worked!

RE: Check GridView and play sound if result is zero!

great glad you got it to work.
and glad you posted in case anyone has the same problem.. thanks

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close