How to show confirm box on textChanged event of text box in ItemTemplate of gridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • md1006
    New Member
    • Jun 2010
    • 1

    How to show confirm box on textChanged event of text box in ItemTemplate of gridview

    I've used textbox in ItemTemplate of gridview. I need a confirm box on textChanged event of the respective text box. If user confirms as Ok/Yes then continue with some code else if user clicks on Cancel/No then do some other action.
    I've tried using:
    Code:
      Page page = HttpContext.Current.Handler as Page;
                        ScriptManager.RegisterClientScriptBlock(page, page.GetType(), "key2", "confirm('Do you want to update?');", true);
    But I was not able to achieve desired output.
    Plz' Help me with this code.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    To prevent a postback to the server return False to the client-side (JavaScript) "onclick" event.

    Try this:
    Code:
     Page page = HttpContext.Current.Handler as Page;
                        ScriptManager.RegisterClientScriptBlock(page, page.GetType(), "key2", "return confirm('Do you want to update?');", true);
    -Frinny

    Comment

    Working...