ASP. NET-Several Common Errors

Source: Internet
Author: User
Tags blank page

I recently learned about ASP. NET and encountered some errors. I have summarized some common errors. I hope this article can help ASP. NET beginners. At the same time, you can record these errors for future reference.

1. The GridView "GridView1" triggers the unprocessed event "PageIndexChanging ".

Error cause: (for example,-1)


(Figure -- 1)

Solution:

When this error occurs, you only need to add the OnPageIndexChanging event to the GridView label and enable OnPageIndexChanging = "GridView2_PageIndexChanging" to add the following functions in the background code:

  protected voidGridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) {this.GridView1.PageIndex= e.NewPageIndex;this.BindToGridView(); }

Ps: for other similar errors, you need to write the corresponding background code, which is not described here.

 

2. HTTP Error 403.14-Forbidden (the Web server is configured to not list the contents of this directory)

Error cause: Generally, the start page is not set for the project (for example, -- 2)

(Figure -- 2)

Solution: Set the start page.

Ps: it is easy to see this type of error after creating a blank page.

 

3. The ControlToValidate attribute of "CompareValidator1" cannot be blank.

Error cause: the ControlToValidate control is not set for the comparison verification control ).

Solution: Set the Control ID to be verified.

General Usage: the "CompareValidator1" control is generally used to verify user input against specific data types to ensure that users enter numbers, dates, and so on, at the same time, it can be used to compare whether the content entered in the two controls to be verified meets your own set expression.

For example, to compare the two passwords, set the properties of the "CompareValidator1" control as follows.

ContorlToCompare

TxtOldPwd

ContorlToValidate

TxtNewPwd

Operator

Equall

ErrorMessage

The two passwords are inconsistent.

Ps: This type of error occurs when you are not familiar with the usage of this type of control and do not understand the meaning of related properties. The validation control in ASP. NET also includes the RequiredFieldValidator control, RangeValidator control, RegularExpressionValidator control, CustomValidator control, and ValidationSummary control.

 

4、“userControlTest.testControl.txt Name "cannot be accessed because it is restricted by the protection level

Error cause: (for example, -- 3)


(Figure -- 3)

 

Solution:

Modify the txtName permission in testControl. ascx. desiger. cs (VS2013 is used ).

Change protected global: System. Web. UI. WebControls. TextBox txtName; To publicglobal: System. Web. UI. WebControls. TextBox txtName;

ASP is used for learning. NET Video, a verification control (ASP. the usage of the verification control in. NET) can also reflect its importance. Therefore, you can focus on the actual manual work in the learning process. Because the video uses VS2005 and my current VS2013, there are still some differences. Therefore, the most common problem during the entire learning process is the use of the GridView control, which may be described separately in another article.


(I hope you will not give me any advice if you have any questions about cainiao)


Copyright reprinted please indicate the source: http://blog.csdn.net/senior_lee/article/details/37041487

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.