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/