Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Based on the fact above what I did is something interesting which I haven't came across earlier.</p> <p>For an instance I have wrote what my problem was. Basically it's the postback error which occurs when you click and select an option from JavaScript, so what you can do is:</p> <p>Create a custom control which is based on extending the <code>System.Web.Ui.WebControls.Dropdownlist</code>, and instead of using <code>&lt;asp:dropdownlist&gt;</code> just use that.</p> <p>Here is the code for that for custom class:</p> <pre><code> public class DropDown:System.Web.UI.WebControls.DropDownList { } </code></pre> <p>To the reference I would give you a very good blog post for that which actually has dealt with this problem which quite didn't help out with my original problem.</p> <p><a href="http://johanleino.wordpress.com/2009/11/17/cascadingdropdown-casues-invalid-postback-or-callback-argument-error/#comment-286" rel="nofollow noreferrer">Postback Error Blog</a></p> <p>But I could actually figure out what was the problem. Basically what happens is when I populate a dropdownlist with a jQuery AJAX on a cascading effect. The viewstate actually doesn't gets updated, so as a result when I click a button for postback it gives the error as:</p> <pre><code>nvalid postback or callback argument. Event validation is enabled using &lt;pages enableEventValidation="true"/&gt; in configuration or &lt;%@ Page EnableEventValidation="true" %&gt; in a page </code></pre> <p>Now to avoid that I have already given the link.</p> <p>Now to solve the problem how to get the value. For that I have put an hiddenfield for the page for the cascading dropdown and have set its value to dropdowns selected value to hiddenfield. Now on button click I can get the actual value from the dropdown (which is basically a custom control) like : </p> <pre><code>$('[id*="btnSubmit"]').click(function() { $('[id*="hf"]').val($('[id*="ddProjectName"]').find("selected").val()); }); Note: You cannot do the textbox1.text = ddcustom.selectedvalue </code></pre> <p>and now you can access the value from button as like:</p> <pre><code>protected void btnSubmit_Click(object sender, EventArgs e) { String Project_id= hf.value; } </code></pre> <p>It's because the viewstate doesn't provide with the client side data which has been changed from cascading effect from jQuery AJAX.</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