Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check GridView and play sound if result is zero!

Status
Not open for further replies.

proximity

Technical User
Sep 19, 2002
132
GB
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.
 
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?:
 
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!
 
great glad you got it to work.
and glad you posted in case anyone has the same problem.. thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top