Regarding the use of the Gridview control on the same page, it is found that the updaeting event cannot be responded to by the server, it seems that its error alarm and then queries some information, and now the solution is summarized as follows: Click the update event cannot respond because the postback or callback parameter is invalid. Event validation is enabled in the configuration with <pages enableEventValidation="true"/> or <%@ Page EnableEventValidation="true" %> on pages. For security purposes, this feature verifies that the parameters of the postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the Clientscrip to remove the tManager.RegisterForEventValidation method to register a postback or callback data for validation.
Description: An unhandled exception occurred during the execution of the current web request. Check the stack trace information for details about the error and where it came from in your code that caused the error.
Exception details: System.ArgumentException: Invalid postback or callback parameters. Event validation is enabled in the configuration with < pages enableEventValidation="true"/> or <% @ Page EnableEventValidation="true" %> on pages. For security purposes, this feature verifies that the parameters of the postback or callback event originate from the server control that originally rendered them. If the data is valid and expected, use the Clientscrip to remove the tManager.RegisterForEventValidation method to register a postback or callback data for validation. After looking at it for a long time, I didn't find any problem, and it was correct to check the code again, and I checked the IDs and attributes of all the controls on the page and still didn't find the problem. Later, I found out that this is what happened: Conditions of occurrence: 1. There are hidden controls on the screen. 2. Multiple Gridview bindings. 3. Nested in multiple forms. Causes of occurrence: . .NET generates a __EVENTVALIDATION hidden field in the final page based on the output elements in the page. A simple test was done. Create a <asp: button id="btnSubmit" runat="server" text="Submit" tooltip="Submit" /> and create the corresponding Click event handler. Run the program and respond correctly to the event. Then set btnSubmit.Visable=false and manually add <input type="submit" name="btnSubmit" value="Submit" /> on the page. Run the program and an exception will appear with the EnableEventValidation content. Set <@Page EnableEventValidation="false" > run the program again to respond correctly to the event. Observing the content of the two __EVENTVALIDATION before and after, it can be found that they are different. Regarding the exception that occurs, it can be considered that btnSubmit is not included in the output, but when it is submitted to the background, there is corresponding content, which is inconsistent, so in the case of event verification enabled. .NET throws an exception.
Solution 1: Page_Load(object sender, EventArgs e)
{ if (! Page.IsPostBack) { bind data; }
} Solution 2: <pages enableEventValidation="false"/> 1. Add EnableEventValidation="false" to the <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> of the page. (First of all)
2. Go through web.config <system.web> <pages enableEventValidation="false"/>
3. It is Form nesting, a page can only have one Form, which can be solved by carefully checking the code.
4. If the page contains controls such as DropDownList or ListBox, it may be caused by the following reasons:
4.1 Using ajax in the drop-down menu is commonly found in the provincial and city linkage menu, which may be due to the fact that the initial item value of the drop-down menu is assigned to the aspx page, and the error is prompted when the event is posted, and the initial item value of the drop-down menu is deleted, and the item item is added to the bound event. 4.2 The reason is that the Value property of the ListItem of the DropDownList control contains Chinese characters. Just change the value to English or a number. It is best to add the following statement in the web.config: <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="zh-CN" uiCulture="zh-CN"/> Because POSTBACK is not encoded in UTF-8, JAVAscrip removing t will be considered problematic. Just change requestEncoding="utf-8" to it, but responseEncoding="utf-8" doesn't
5.Register For Event Validation The principle is to let asp.net record this postback value. RegisterForEventValidation must be called on render.
|