The postback or callback argument is invalid "HtmlSelect" cannot have a child of type "LiteralControl"

Source: Internet
Author: User

The original Published time: 2009-11-14--from my Baidu article [imported by moving tools]

The postback or callback argument is invalid "HtmlSelect" cannot have a child of type "LiteralControl" with these two errors, generally. NET2.0 encountered in the error, Resolved:

The postback or callback parameter is invalid. Use <pages enableeventvalidation= "true" in the configuration/> or use <%@ page enableeventvalidation= "true"%> to enable event validation. For security purposes, this feature verifies that the parameters of the postback or callback event originate from the server control that originally rendered the events.
There are two types of occurrences that have been encountered so far:
One is nested form, a page can only have a form, carefully check the code can be resolved.
The second is to use JavaScript in the drop-down menu to change content (such as Ajax), which is common in the provincial and municipal linkage menu, prompting for the error when the event is posted back.

This error occurs only on VS 2.0, and if you change the enableeventvalidation= "true" to enableeventvalidation= "false" the error is no problem, but the value of this item is not read in the code.

In the first case, you can't embed a form in a form.
The second solution is to change the control to Html control, with the control runat= "Server"

For example: Here is one of my solutions

The chain effect of a province and city
Province
<asp:dropdownlist id= "DropDownList3" runat= "Server" >
</asp:DropDownList>

City
<select name= "ddlcity" id= "ddlcity" runat= "Server" >
<option value= "0" > = Please select = </option>
</select>

Then in the background CS code with request.form["Ddlcity"]; To receive the value of the city.

====================

If "HtmlSelect" cannot have a child of type "LiteralControl" after following the above method, there are generally two reasons:

1. Cause of Error:

The <select> tag, Id, and value values in <option> are not enclosed in quotation marks.

Processing results:

When all id,value are enclosed in double quotes, the bug disappears.

2, in <select id= "xxx" runat= "server" > This line is followed by comments <!---->
Process The result: Remove the comment, or comment do not write in the select tag without error.

The postback or callback argument is invalid "HtmlSelect" cannot have a child of type "LiteralControl"

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.