Button-click's client-side alert shows only once per page load, why?

Discussion in 'ASP .Net' started by gnewsgroup, Dec 20, 2007.

  1. gnewsgroup

    gnewsgroup Guest

    I have a gridview, in which people can click on a delete button to try
    to delete something from the database.

    But, if that selected row cannot be deleted (because, for example, it
    is referred to by some other table in the database), I show an alert
    like

    "An order is associated with this customer, and therefore it cannot be
    deleted."

    I did this in code-behind through

    ScriptManager.RegisterClientScriptBlock(
    this.Page,
    this.GetType(), "customer_is_not_deleted",
    "alert(\"An order is associated with this customer, and
    therefore it cannot be deleted.\");",
    true);

    It works, but only once. Upon the second, 3rd, ..., click, the alert
    does not pop up. It work once again if the page is reloaded.

    I am using AJAX, I guess it has to do with AJAX. But any workaround if
    I want to keep the AJAX?
     
    gnewsgroup, Dec 20, 2007
    #1
    1. Advertising

  2. gnewsgroup

    bruce barker Guest

    RE: Button-click's client-side alert shows only once per page load, wh

    if its an ajax postback, for the client script to be sent to the client and
    eval'd, the control specified in RegisterClientScriptBlock must be one of the
    active update panels or one of its children.

    -- bruce (sqlwork.com)


    "gnewsgroup" wrote:

    > I have a gridview, in which people can click on a delete button to try
    > to delete something from the database.
    >
    > But, if that selected row cannot be deleted (because, for example, it
    > is referred to by some other table in the database), I show an alert
    > like
    >
    > "An order is associated with this customer, and therefore it cannot be
    > deleted."
    >
    > I did this in code-behind through
    >
    > ScriptManager.RegisterClientScriptBlock(
    > this.Page,
    > this.GetType(), "customer_is_not_deleted",
    > "alert(\"An order is associated with this customer, and
    > therefore it cannot be deleted.\");",
    > true);
    >
    > It works, but only once. Upon the second, 3rd, ..., click, the alert
    > does not pop up. It work once again if the page is reloaded.
    >
    > I am using AJAX, I guess it has to do with AJAX. But any workaround if
    > I want to keep the AJAX?
    >
     
    bruce barker, Dec 20, 2007
    #2
    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. =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
    Replies:
    2
    Views:
    6,496
    rick74
    May 27, 2008
  2. Mark Adams
    Replies:
    0
    Views:
    364
    Mark Adams
    Nov 13, 2005
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,970
    Smokey Grindel
    Dec 2, 2006
  4. Aymer
    Replies:
    1
    Views:
    389
    Alvin Bruney
    Sep 19, 2003
  5. Jack
    Replies:
    4
    Views:
    190
    Phillip Windell
    Nov 26, 2003
Loading...

Share This Page