[Video] It's very strange! -- The bug that listview executes page. Validate () randomly

Source: Internet
Author: User

Today, when I was doing my website, I encountered a very disgusting situation:

There are two user controls on the page, one of which contains listview, used to display the product comment list, and the other is the submission information interface for posting comments.

The listview in the user control used to display the comment List supports the edit mode, which is used by the landlord to reply to the comment, which is roughly like this:

The strange thing is that when you submit a reply, sometimes the verification of the user control that posted the comment below is triggered, so that the following published control prompts that NO content, verification code, and so on are entered, the submission is also canceled.

I group all the verification controls and buttons in the two controls, and set the causesvalidation attribute of all buttons in the listview to false, that is, no verification is triggered. Try again and the problem persists.

The strange thing is that the same operation and the same environment may occur, but sometimes the same operation may not occur. If the previous operation is successful, an error occurs when the task is executed immediately, the error rate is high.

After studying for a long time, I could not find the problem, and I did not trigger any verification.CodeLater, I overwritten the page. Validate () method and set breakpoint monitoring for it:

After clicking submit, it is often executed after the page and all the load functions of the control are executed, rather than the listviewdomainitemupdating event, but as mentioned above, in this case, it is still uncertain. Sometimes the listviewdomainitemupdating event can be executed smoothly. I perform continuous tests frequently and the results are still uncertain.

Here is the test video:

Clear Version Download: Release

Even if the validate () method is rewritten in this way, it is useless:

Public override void validate ()
{
Foreach (ivalidator F in this. validators)
{
F. isvalid = true;
}
}

This method is still triggered randomly at the time of sending back. After validate () is executed, the listviewdomainitemupdating event is still not executed.

(You may have noticed a rule in the video above: an error occurs when the same entry is modified to the second time, but when I rewrite the method as above and then perform a test, this rule disappears, it can be said that it is completely random ......Is this the legendary quantum uncertainty ?!?!?:

Clear Version Download: Release

No breakpoint is set here. If the submission is still not completed after validate () is executed, the page will jump to the following page (probably because there is a verification control below, but I don't know why the error prompt is not displayed)

I did not find any helpful content when searching and searching on the Internet. It seems that this old man is still in no solution, but I can see that msdn has such a saying:

Http://msdn.microsoft.com/zh-cn/library/0ke7bxeh.aspx

It is clearly described as"In ASP. NET 2.0, the control no longer calls the page. Validate () method.", Are all listview 3.5 controls? Why are calls frequently?

 

To prove that it is not a side effect of a code segment on my website, I created a blank website project and added only one listview to the homepage:

Then rewrite validate () and set the breakpoint according to the above method to test:

 

Go to validate () again:

This test is different from the previous one: Each update must come here, and never executed listview1_itemupdating once. After validate () is complete, it will be directly returned to the client ~~ More confused ......

The page does not even have a control to be verified. Why ??

I still set the causesvalidation attribute of all buttons to false and assign them a verification group.

 

Then, let's test whether other controls or pages have such problems. I have created a new page and placed it in a button and drop-down list:

Each of them is assigned a send-back event, and then rewrite validate () and set the breakpoint:

After testing, the validate () method is not triggered no matter how hard it is, which means that the conventional control does not trigger this method.

 

Download the source code of the test website Project: Development

 

What is the willingness of listview to trigger the obsolete validate () method?

What causes it to be triggered at random upon sending back? (--Do we need to use the schödnex equation for control ~)

Why do I still fail to execute the send-back event after I set all the verification controls to pass or if there is no verification control at all?

This is so fast that I can vomit blood. It's capricious, irregular, and disgusting. Please give me some answers, or do you have any way to disable listview from performing validate ~

(Note: My listview is not bound to any data source and implements various operation logic by myself. Refer to this 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.