Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't know exactly what's the role of JQuery for your scenario. I imagine you want to show some sort of fancy confirmation box, if you provide the details I'll provide a more concrete answer, but for now, this is how is done with pure javascript:</p> <pre><code>GridView1_RowCreated(Object sender, GridViewRowEventArgs e) { LinkButton lb = new LinkButton(); lb.Text = "something"; lb.ID = "someId"; lb.OnClientClick = "javascript: return confirm('Are you sure that you want to do this and that?'); "; TableCell cell = new TableCell(); cell.Controls.Add(lb); e.Row.Cells.Add(cell); } </code></pre> <p><strong>UPDATE</strong> - Try something like this for the JQuery UI approach</p> <ol> <li><p>have a div with id="dialog-confirm" in your markup as so:</p> <pre><code> &lt;div id="dialog-confirm" title="" &gt;&lt;/div&gt; </code></pre></li> <li><p>Define a javascript function called showConfirmation as so:</p> <pre><code> function showConfirmation(confirmationMessage) { $("#dialog-confirm").dialog("destroy"); $( "#dialog-confirm" ).dialog({ resizable: false, height:140, title: confirmationMessage, modal: true, buttons: { "Yes": function() { $( this ).dialog( "close" ); __doPostBack(linkItemID, '');//will cause postback }, Cancel: function() { $( this ).dialog( "close" ); } } }); return false; //it will never postback } </code></pre></li> <li><p>Now your code behind should look like this:</p> <pre><code> GridView1_RowCreated(Object sender, GridViewRowEventArgs e) { LinkButton lb = new LinkButton(); lb.Text = "something"; lb.ID = "someId"; lb.OnClientClick = "return showConfirmation('Are you sure you want to do this and that?','"+lb.ID+"'); "; TableCell cell = new TableCell(); cell.Controls.Add(lb); e.Row.Cells.Add(cell); } </code></pre></li> </ol> <p>Note: Code above hasn't been tested but that should be very very close to what you need.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload