How to prevent a page postback according to user choice

Discussion in 'ASP .Net Web Controls' started by Joe Abou Jaoude, Jan 12, 2005.

  1. hi,

    i have a linkbutton that deletes records from the database. I want to be
    sure that the user didn't press it unintentionally , so on the client
    side I want to use an alert window to make the user confirm his request
    before posting the page to the server.

    my question is how can i postback the page if the user presses the yes
    button in the alert window and ho can i prevent the postback when the
    user presses No

    thank you

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Joe Abou Jaoude, Jan 12, 2005
    #1
    1. Advertising

  2. Joe Abou Jaoude

    anon Guest

    The way I have hacked this before is to use a custom validator that asks the
    user if they wish to continue but only if a page variable was set (say
    "linkclick"). Declare this variable within the page (javascript) and set it
    as 0. Then in your code add the onClick attribute for your linkbutton to be
    "linkclick=1;" - the ; is important as dotnet will append postback logic to
    this.

    e.g. linkClick.Attributes.Add("onClick", "linkclick=1;");

    That way the the validator will ask the user and control whether it should
    post back or not when ever the use clicks the link but not another button.
    Remember to reset linkclick=0 when the user says responds no.

    D

    "Joe Abou Jaoude" <> wrote in message
    news:%23p%23FqyJ%...
    >
    >
    > hi,
    >
    > i have a linkbutton that deletes records from the database. I want to be
    > sure that the user didn't press it unintentionally , so on the client
    > side I want to use an alert window to make the user confirm his request
    > before posting the page to the server.
    >
    > my question is how can i postback the page if the user presses the yes
    > button in the alert window and ho can i prevent the postback when the
    > user presses No
    >
    > thank you
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    anon, Jan 15, 2005
    #2
    1. Advertising

  3. clever solution.
    thx

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Joe Abou Jaoude, Jan 17, 2005
    #3
    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. Mickey Segal
    Replies:
    0
    Views:
    913
    Mickey Segal
    Feb 2, 2004
  2. Zeba
    Replies:
    6
    Views:
    442
    Mark Rae
    Feb 27, 2007
  3. miles.jg
    Replies:
    16
    Views:
    895
    Alf P. Steinbach
    Nov 14, 2007
  4. Carlos
    Replies:
    2
    Views:
    837
    Carlos
    Jul 2, 2008
  5. Alex
    Replies:
    11
    Views:
    600
    Jeremy Sanders
    Aug 8, 2008
Loading...

Share This Page