ListItems attributes in a DropDownList are lost on postback?

I had the same problem and wanted to contribute this resource where the author created an inherited ListItem Consumer to persist attributes to ViewState. Hopefully it will save someone the time I wasted until I stumbled on it. protected override object SaveViewState() { // create object array for Item count + 1 object[] allStates = … Read more

What is a postback?

The following is aimed at beginners to ASP.Net… When does it happen? A postback originates from the client browser. Usually one of the controls on the page will be manipulated by the user (a button clicked or dropdown changed, etc), and this control will initiate a postback. The state of this control, plus all other … Read more

How to use __doPostBack()

You can try this in your web form with a button called btnSave for example: <input type=”button” id=”btnSave” onclick=”javascript:SaveWithParameter(‘Hello Michael’)” value=”click me”/> <script type=”text/javascript”> function SaveWithParameter(parameter) { __doPostBack(‘btnSave’, parameter) } </script> And in your code behind add something like this to read the value and operate upon it: public void Page_Load(object sender, EventArgs e) { … Read more

Invalid postback or callback argument. Event validation is enabled using ”

Do you have code in your Page_Load events? if yes, then perhaps adding the following will help. if (!Page.IsPostBack) { //do something } This error is thrown when you click on your command and the Page_load is being ran again, in a normal life cycle it would be Page_Load -> Click on Command -> Page_Load … Read more