-3

I want to ring a bell in a website if the string value = "UP". I have tried to console. beeps (), its working in local machine but not in remote as its a website. how to ring a bell in web applications.

                   if  (status !="DN")
                    {
                    Console.Beep(5000, 1000);
                    }
Anil
  • 3,722
  • 2
  • 24
  • 49
Swapna
  • 403
  • 3
  • 6
  • 24
  • play sound on server or client browser, what is this mvc or simple asp? – Anil Mar 09 '17 at 07:59
  • client browser. i mean user uses website.in the website it should give alert – Swapna Mar 09 '17 at 08:00
  • 1
    Possible duplicate of [how to play a sound in asp.net web page?](http://stackoverflow.com/questions/12329191/how-to-play-a-sound-in-asp-net-web-page) – Anil Mar 09 '17 at 08:00
  • i used this but not working . what should i change if i have a sound file in sounds folder . Response.Write(""); – Swapna Mar 09 '17 at 08:39
  • I'm imagining a dev server in a datacenter somewhere beeping wildly. – Daniel Mann Mar 09 '17 at 12:24

1 Answers1

0

use <object> or <embed> html tags and make these as server control, runat="server" and give them Ids.

<object id="audiofile" runat="server" data=""></object>
Or HTML5 tag

<audio id ="audioTag" runat="server" src="">
  <p>This browser does not support audio.</p>
</audio>

In code behind check browser and set the src to audio tag if its html5 supportive else to object

     if  (status !="DN")
                        {
         if(!html5browser)
                        audiofile.attributes.add("data","path/audiofile");
        else
                   audiotag.attributes.add("src","path/audiofile");
                        }

Using Response.write

Response.Write("<embed height='0' width='0' src='path/audiodile' />");
Anil
  • 3,722
  • 2
  • 24
  • 49
  • in your answer, what do u mean by path , in my case what will be the path.my file location is "D:\..\..\..\applicationName\sounds" – Swapna Mar 09 '17 at 11:33
  • 1
    resource path: https://msdn.microsoft.com/en-us/library/ms178116.aspx and this also http://stackoverflow.com/questions/29080367/how-to-get-the-path-to-image-stored-in-content-folder-net – Anil Mar 09 '17 at 11:48