Asp.net page. enableeventvalidation attribute to verify the Server Control's sending and callback events

Source: Internet
Author: User

I thought the page would be simple, but the following error occurred during running:

For details about the page. enableeventvalidation attribute, refer to msdn to get or set a value. This value indicates whether the page verifies the send-back event or the verification callback event .. For security considerations, the Net Framework registers the sending and callback events of the server-side controls. This event verification mechanism can eliminate the risks caused by unauthorized sending requests and callbacks. With this model, the control registers its events during rendering, and then verifies these events during sending back or callback. By default, all event-driven controls in ASP. NET use this function.

First, since event verification is enabled, disable verification on the page. <% @ page enableeventvalidation = "false" %> the problem is resolved. But why is there such a problem? Google it.

If the page contains controls such as dropdownlist or ListBox, the following causes may occur:

Ajax is used in the drop-down menu, which is common in the provincial/municipal linkage menu. It may be because the initial item value is assigned to the drop-down menu on the ASPX page. This error is prompted when the event is returned, delete the initial item value from the drop-down menu and add the item to the binding event.

The reason is that the value attribute of the listitem in the dropdownlist control contains Chinese characters. You only need to change the value to English or numbers. You 'd better Add the following statement to Web. config:CopyCodeThe Code is as follows: <globalization requestencoding = "UTF-8" responseencoding = "UTF-8" Culture = "ZH-CN" uiculture = "ZH-CN"/>

Because PostBack does not use UTF-8 encoding, JavaScript will think there is a problem. Only change requestencoding = "UTF-8. If you have other suggestions, please note.

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.