Let's take a look at whether this is A. NET Vulnerability or a program problem. I didn't know it for a moment, but I only knew it was a strange problem.

Source: Internet
Author: User

CodeAs follows:

1.Webform1.aspx

<% @ Page Language = "C #" codebehind = "webform1.aspx. cs" autoeventwireup = "false" inherits = "webapplication4.webform1" %>

<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">

<HTML>

<Head>

<Title> webform1 </title>

<Meta name = "generator" content = "Microsoft Visual Studio. NET 7.1">

<Meta name = "code_language" content = "C #">

<Meta name = "vs_defaultclientscript" content = "JavaScript">

<Meta name = "vs_targetschema" content = "http://schemas.microsoft.com/intellisense/ie5">

<Script language = "JavaScript">

Function AA ()

{

// Document. All. label1.innerhtml = "OK ";

// Alert ("AA ");

Document. getelementbyid ('button2'). Click ();

}

</SCRIPT>

</Head>

<Body ms_positioning = "gridlayout">

<Form ID = "form1" method = "Post" runat = "server">

<Font face ="">

<Asp: Label id = "label1" style = "Z-INDEX: 101; left: 304px; position: absolute; top: 64px" runat = "server"> </ASP: Label>

<Asp: button id = "button1" style = "Z-INDEX: 102; left: 360px; position: absolute; top: 136px" runat = "server"

TEXT = "button1"> </ASP: button>

<Asp: button id = "button2" style = "Z-INDEX: 103; left: 320px; position: absolute; top: 208px" runat = "server"

TEXT = "button2"> </ASP: button> </font>

</Form>

</Body>

</Html>

2.Webform1.aspx. CS

InPage_load

Private VoidPage_load (ObjectSender, system. eventargs E)

{

If(! Ispostback)

{

This. Button1.attributes. Add ("onclick", "AA ()");

}

}

 

Add eventButton2

Private VoidButton2_click (ObjectSender, system. eventargs E)

{

This. Label1.text = "OK ";

}

Code is very simple
Running result

Click "Button1" Button , In Button2 Add a breakpoint to the event as follows:


YesButton2Event (it should be said thatLabel1The value is"OK")

But the result is

I don't know why label1 is empty. Can someone explain it ??
Source code:

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.