The callback parameter is invalid. Use <pages enableeventvalidation = "true"/> in the configuration, or use <% @ page enableeventvalidation = "true" %> On the page to enable event verification.

Source: Internet
Author: User

The callback parameter is invalid. Use <pages enableeventvalidation = "true"/> in the configuration, or use <% @ page enableeventvalidation = "true" %> On the page to enable event verification. For security purposes, this function verifies whether the parameters of the send-back or callback events come from the server controls that initially present these events. If the data is valid and is expected, use the clientscriptmanager. registerforeventvalidation method to register the resend or callback data for verification.

1.Cause:If you directly use databind () in pageload, When you activate the event of embedding controls in the gridview, PostBack is triggered, however, you did not judge whether the data binding at this time is still the first execution of pageload's datebind (). However, you have triggered events such as updates and deletions, in this case, the above error "verify whether the parameters of the send-back or callback events are derived from the server control that originally presented these events" is generated.

2.Solution:Write the binding statement in! In ispostback,

Protected void page_load (Object sender, eventargs E)
{
If (! Ispostback)
{
// Data binding statement
}
}

3.Ispostback:

indicates whether the current request is opened for the first time. page. ispostback or ispostback or This. ispostback or This. page. ispostback , which are equivalent.
1) It is the first time that a URL is opened through the address bar of IE, when you submit a server by clicking the submit button on the page or the button that can cause the request to be submitted in post mode, the page is no longer opened for the first time. (Each click is loaded once)
2) ispostback is only available in for the first time , the value is false. For other times, the value is true.
3 ). net: request. form. count> 0
4) when loading a page, set put the code to ispostback each time, you only need to load the code once in if (! Ispostback.
5) The ispostback attribute is triggered every time the user returns any information from the server to determine whether the user is No Logon events or other events
6)

If (! Ispostback) // only when it is enabled for the first time,
{
response. write ("first submission! ");
}
If (ispostback)
{
response. write ("click the button! ");
}

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.