Why would the same web form control render different "onclick" logic based on the page structure?

Posted by zk812 on Stack Overflow See other posts from Stack Overflow or by zk812
Published on 2010-03-22T14:28:39Z Indexed on 2010/03/22 14:31 UTC
Read the original article Hit count: 216

Filed under:
|

It was hard to title this question. :)

I have a user control that is used to display a list of lookup items in my database and a delete button for each item (Editor User Control below). The delete button has an onClientClick event used to display a confirmation dialog in JavaScript.

On page one, the confirmation pops up and functions correctly. The overall structure is:

  • Master Page
    • Page
      • Editor User Control
        • List of items with delete button

On page two, the confirmation pops up but regardless of the answer, the page posts back anyway. The structure of this page is:

  • Master Page
    • Page
      • User Control
        • Editor User Control
          • List of items with delete button

For some reason, this makes a difference in how the delete button is rendered.

Page one:

<input type="image" name="ctl00...RequestTypesDataList$ctl01$ctl01" src="Images/Disable.png" alt="Delete" onclick="return ProcessDeleteCommand(1);" />

Page two:

<input type="image" name="ctl00...RequestTypesDataList$ctl07$ctl01" src="Images/Disable.png" alt="Delete" onclick="return ProcessDeleteCommand(2);WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ContentPlaceHolder1$RequestCreator1$RequestTypeEditor1$RequestTypesDataList$ctl07$ctl01&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" />

Does anyone know why page two renders WebForm_DoPostBackWithOptions after my JS check? It's causing the postback regardless of the confirmation choice.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript