大家看一下这是.net的漏洞还是程序有问题,我一时也没搞清,只知道这问题挺怪的

 

代码如下:

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

Page_Load中

private void Page_Load(object sender, System.EventArgs e)

     {

          if(!IsPostBack)

         {

              this.Button1.Attributes.Add("onclick","aa()");

         }

}

 

添加事件Button2

private void Button2_Click(object sender, System.EventArgs e)

{

     this.Label1.Text="Ok";

}

代码非常简单
运行结果



单击”Button1”按钮,Button2事件中添加断点如下


 

是能够进入Button2事件的(应该说Label1的值是”Ok”

但结果会是



不知道Label1为空,为什么有谁可以解释一下吗??
源代码:

posted on 2005-10-24 21:05 surprise 阅读(927) 评论(4) 编辑 收藏

评论

#1楼  回复 引用   

将form的id改掉,试一试!
2005-10-25 16:37 | kyky_2[未注册用户]

#2楼  回复 引用   

把 this.Button1.Attributes.Add("onclick","aa()");
改为 this.Button1.Attributes.Add("onclick","aa();return false;");

2005-10-27 09:57 | __路过__

#3楼  回复 引用 查看   

没有问题啊,我把你的源代码运行了一编,Labe1 为空啊,可以是你的.net 有问题,重新装一下Visual Studio 2003
2005-11-16 15:49 | ctrl+alt      

#4楼  回复 引用 查看   

没有问题啊,我把你的源代码运行了一编,Labe1 为ok啊,可以是你的.net 有问题,重新装一下Visual Studio 2003
2005-11-16 15:50 | ctrl+alt      

导航

<2005年10月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

公告

昵称:surprise
园龄:7年6个月
粉丝:3
关注:0

搜索

 
 

常用链接

随笔档案

好友

最新评论

阅读排行榜

评论排行榜

推荐排行榜