Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First I will like to explain the <code>Disadvantage</code> of using the <code>Update Panel</code> using the very same example posted by you.</p> <h2>Below is the Original Code</h2> <p><img src="https://i.stack.imgur.com/wQvPW.png" alt="enter image description here"></p> <hr> <h2>Output</h2> <p><img src="https://i.stack.imgur.com/EMx6z.png" alt="enter image description here"></p> <hr> <p>To display the 22 character string you can check how much data is being received and sent to server. Just imagine following</p> <ol> <li>If you would consider send each request to <code>Database</code> using <code>Update Panel</code> and your <code>GridView</code> is in <code>Update Panel</code>!!!!!!</li> <li>Suppose you would use <code>ViewState</code> data for each request and with <code>GridView Inside the Update Panel</code>.</li> </ol> <p>Both the above techniques are worst as per my understanding.</p> <hr> <p>Now I will describe you <code>Page Methods</code></p> <h2>Page Method over Update panel</h2> <p><code>Page Methods</code> allow <code>ASP.NET AJAX</code> pages to directly execute a <code>Page’s Static Methods</code>, using <code>JSON (JavaScript Object Notation)</code>. Instead of posting back and then <code>receiving HTML markup</code> to completely replace our <code>UpdatePanel’s contents</code>, we can use a <code>Web Method</code> to request only the information that we’re interested.</p> <h2>Sample Code</h2> <p><img src="https://i.stack.imgur.com/FDEF5.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/z2sK0.png" alt="enter image description here"></p> <hr> <h2>Output</h2> <p><img src="https://i.stack.imgur.com/dMehB.png" alt="enter image description here"></p> <p>Hope this clearly explains the difference of usage.</p> <hr> <h2>Answer to the original Query</h2> <p>You have to register the <code>ItemDataBound</code> event of the below <code>Repeater</code> and use below code for it.</p> <h2>Code Behind</h2> <pre><code>protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Button btn = (Button)e.Item.FindControl("Button1"); btn.OnClientClick = string.Format("SubmitButton('{0}');return false;" , HiddenButton.ClientID); } } </code></pre> <hr> <h2>JavaScript</h2> <pre><code>&lt;script type="text/javascript"&gt; function SubmitButton(btn) { $("#" + btn).click(); } &lt;/script&gt; </code></pre> <h2>//Alternative</h2> <pre><code>&lt;script type="text/javascript"&gt; function SubmitButton(btn) { document.getElementById(btn).click(); } &lt;/script&gt; </code></pre> <hr> <p><strong><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.rendermode.aspx" rel="noreferrer">Reference</a></strong> &amp; <strong><a href="http://encosia.com/why-aspnet-ajax-updatepanels-are-dangerous/" rel="noreferrer">Here</a></strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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