Solve the problem that the callback or callback parameter is invalid when Ajax is used to dynamically add data to the dropdownlist.

Source: Internet
Author: User

It took four hours to finally solve the problem.

1. Change the <asp: dropdownlist/> server control to an HTML server: <select id = "XXX" runat = "server"> </SELECT>.

2. Because runat = server is added, the operation is the same as the general dropdownlist. Bind can also be performed.

3. When the value is submitted, write as follows:

Classid = Request [xxx. uniqueid];

 

4. If it is in the user control, write as follows:

Htmldown = (System. Web. UI. htmlcontrols. htmlselect) This . Usercontrolblogclass1.findcontrol ( " Xxx " );
Classid = Request [htmldown. uniqueid];

 

Cause analysis:

Because a new item is dynamically added to the dropdownlist, the items in the dropdownlist do not match the items recorded in the hidden domain. Therefore, the "sending back or callback parameter is invalid" problem occurs.

It is also said on the Internet that the clientscript. registerforeventvalidation method registers items in the hidden domain through the protected override void render (system. Web. UI. htmltextwriter writer) event. I tried it many times and it was not successful.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.