Close alert

Discussion in 'ASP .Net' started by David C, Oct 7, 2009.

  1. David C

    David C Guest

    I have an aspx page with Javascript that shows a message from a hidden
    textbox as shown below.

    var vmsg = document.getElementById('txtMsg');
    if (vmsg.value != '') {
    alert(vmsg.value);
    document.getElementById('txtMsg').value = '';
    }


    I would like to have the alert box display for 3 seconds and then close. I
    have tried the window.setTimeout with no success. Is there a way to
    accomplish this? Thanks.

    David
    David C, Oct 7, 2009
    #1
    1. Advertising

  2. On Oct 7, 6:25 pm, "David C" <> wrote:
    > I have an aspx page with Javascript that shows a message from a hidden
    > textbox as shown below.
    >
    >     var vmsg = document.getElementById('txtMsg');
    >     if (vmsg.value != '') {
    >         alert(vmsg.value);
    >         document.getElementById('txtMsg').value = '';
    >     }
    >
    > I would like to have the alert box display for 3 seconds and then close.  I
    > have tried the window.setTimeout with no success.  Is there a way to
    > accomplish this?  Thanks.
    >
    > David


    I think, you can't do this with JavaScript. You can do a hidden div
    and show it instead of alert function, like in the example below:

    http://forums.tizag.com/archive/index.php?t-961.html
    Alexey Smirnov, Oct 7, 2009
    #2
    1. Advertising

  3. David C

    David C Guest

    "Alexey Smirnov" <> wrote in message
    news:...
    On Oct 7, 6:25 pm, "David C" <> wrote:
    > I have an aspx page with Javascript that shows a message from a hidden
    > textbox as shown below.
    >
    > var vmsg = document.getElementById('txtMsg');
    > if (vmsg.value != '') {
    > alert(vmsg.value);
    > document.getElementById('txtMsg').value = '';
    > }
    >
    > I would like to have the alert box display for 3 seconds and then close. I
    > have tried the window.setTimeout with no success. Is there a way to
    > accomplish this? Thanks.
    >
    > David


    I think, you can't do this with JavaScript. You can do a hidden div
    and show it instead of alert function, like in the example below:

    http://forums.tizag.com/archive/index.php?t-961.html

    Is there any asp.net solution, e.g. via Ajax popup control or something?
    The process I need is on a asp:button click event Thanks.

    David
    David C, Oct 7, 2009
    #3
  4. On Oct 7, 9:17 pm, "David C" <> wrote:
    > "Alexey Smirnov" <> wrote in message
    >
    > news:...
    > On Oct 7, 6:25 pm, "David C" <> wrote:
    >
    > > I have an aspx page with Javascript that shows a message from a hidden
    > > textbox as shown below.

    >
    > > var vmsg = document.getElementById('txtMsg');
    > > if (vmsg.value != '') {
    > > alert(vmsg.value);
    > > document.getElementById('txtMsg').value = '';
    > > }

    >
    > > I would like to have the alert box display for 3 seconds and then close.. I
    > > have tried the window.setTimeout with no success. Is there a way to
    > > accomplish this? Thanks.

    >
    > > David

    >
    > I think, you can't do this with JavaScript. You can do a hidden div
    > and show it instead of alert function, like in the example below:
    >
    > http://forums.tizag.com/archive/index.php?t-961.html
    >
    > Is there any asp.net solution, e.g. via Ajax popup control or something?
    > The process I need is on a asp:button click event Thanks.
    >
    > David


    You can try PopupControl

    http://www.asp.net/AJAX/AjaxControlToolkit/Samples/PopupControl/PopupControl.aspx

    But asp:button has OnClientClick method which can be used to call
    client scripts:

    For example:
    <asp:Button ... OnClientClick='setTimeout("hidebox()", 5000);'>

    Hope this helps
    Alexey Smirnov, Oct 7, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RJN
    Replies:
    1
    Views:
    2,998
    bruce barker
    Sep 29, 2004
  2. Mersh
    Replies:
    0
    Views:
    477
    Mersh
    Mar 13, 2007
  3. Ganesh
    Replies:
    0
    Views:
    539
    Ganesh
    Jun 29, 2007
  4. Iñaki Baz Castillo
    Replies:
    7
    Views:
    821
    Iñaki Baz Castillo
    Jan 12, 2010
  5. BWGames

    Alert box then close window

    BWGames, May 3, 2004, in forum: Javascript
    Replies:
    2
    Views:
    136
    Thomas 'PointedEars' Lahn
    May 24, 2004
Loading...

Share This Page