ASP. NET naming lessons: Avoid keywords whenever possible

Source: Internet
Author: User

The Tutorial at (www.bkjia.com) hopes that you will develop good naming rules when designing programs, even if you are doing a Demo, otherwise the error may make you creazy! Which of the following is my reference material! An extremely simple instance. You can guess if the program runs properly!

The aspx page code is as follows:

Copy to ClipboardReference: [www.bkjia.com] <% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "Test. aspx. cs" Inherits = "LinqWeb. Test" %>

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> bkjia.com </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<Asp: Button runat = "server" ID = "submit" Text = "Button" OnClick = "submit_Click"/>
<Asp: LinkButton ID = "LinkButton1" runat = "server" OnClick = "LinkButton1_Click"> LinkButton </asp: LinkButton>
</Div>
</Form>
</Body>
</Html>

The following is the background code:

Copy to ClipboardReference: [www.bkjia.com] using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. WebControls;

Namespace LinqWeb
{
Public partial class Test: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{

}

Protected void linkbutton#click (object sender, EventArgs e)
{
Response. Write ("<script> alert ('OK') </script> ");
}

Protected void submit_Click (object sender, EventArgs e)
{
Response. Write ("<script> alert ('button event') </script> ");
}
}
}

Are there any mistakes? Who can find them? I admire him. There are indeed no mistakes! However, the following error occurs when we click the LinkButton during running.

Why is this error? Ask Microsoft. When we use the debugging function of IE8, we will find that

Now you should understand whether there is any code that finds a yellow background. There is a method called submit (). Here it can be said that it is a small Bug of asp.net, maybe.. net parses the server control into a conflict with the generated javascript code when the html control is sent to the client, resulting in incorrect javascript call.

Author blog: http://www.cnblogs.com/KevinPan/

Related 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.