Javascript confirm error

2 posts, 0 answers
  1. Madu
    Madu avatar
    7 posts
    Member since:
    Jul 2007

    Posted 16 Jun 2008 Link to this post

    im using asp multiview control with two views. view1 for radgrid for item listing.
    view2 for add/edit item detail. i have added,

    btnDelete.Attributes.Add("onclick","javascript: return confirm('Are you sure?');")

    this method doesnt make a postback event i selected ok from the confirm dialog.
    when i make a change to this (found from your forum)

    btnDelete.Attributes.Add("onclick","javascript: if(confirm('Are you sure?')!=true return false;")

    then it give an javascript error.

    when make property change in the button
    CauseValidation = "false"
    it works fine.

  2. Daniel
    Daniel avatar
    4949 posts

    Posted 18 Jun 2008 Link to this post

    Hello Madu,

    The error in the second expression is caused by a missing bracket. The code below should work as expected:
    Button1.Attributes.Add("onclick""javascript: if(confirm('Are you sure?')!=true) return false;"); 

    Both the first and the second code snippets invoke the Page_Load. I made an example to check this behavior. Please take a look at the attached file.

    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top