javascript检测。在回送

80酷酷网    80kuku.com

  
<body MS_POSITIONING="GridLayout">
  <form id="Form1" method="post" runat="server">  
   <asp:Button id="Button1" 101; LEFT: 16px; POSITION: absolute; TOP: 192px" runat="server"
    Text="服务器1"></asp:Button>  
   <asp:TextBox id="TextBox1" 102; LEFT: 16px; POSITION: absolute; TOP: 24px" runat="server"
    Height="144px" Width="280px" TextMode="MultiLine"></asp:TextBox>
   <asp:Label id="Label1" 103; LEFT: 32px; POSITION: absolute; TOP: 248px" runat="server"
    Height="96px" Width="248px">Label</asp:Label>
   <INPUT 104; LEFT: 192px; POSITION: absolute; TOP: 192px" type="button"
    value="客户" id="bt11" onclick="aa();">
   <asp:Button id="Button2" 105; LEFT: 104px; POSITION: absolute; TOP: 192px" runat="server"
    Text="服务器2"></asp:Button>
   <asp:Label id="Label2" 106; LEFT: 312px; POSITION: absolute; TOP: 248px" runat="server"
    Width="208px" Height="88px">Label</asp:Label>
   <asp:HyperLink id="HyperLink1" 107; LEFT: 400px; POSITION: absolute; TOP: 32px"
    runat="server" NavigateUrl="select_test.aspx">select_text</asp:HyperLink>
  </form>
  <script language="javascript">
   function aa()
   {    
     //用这个方法获取服务器端控件的数值。用DOM对页面上的元素操作
     alert(document.getElementById('TextBox1').value+"---服务器控件数值");         
     //在让客户端代码触发回送事件。   
     alert("客户端触发事件");
     document.getElementById('Button1').click();   
   }
  
  </script>
 </body>

 private void Button1_Click(object sender, System.EventArgs e)
  {
     this.Label1.Text=this.TextBox1.Text;           
           this.Button2_Click(sender,e);//引发按扭2事件
  }

  private void Button2_Click(object sender, System.EventArgs e)
  {
    this.Label2.Text=this.TextBox1.Text;
  }



-------------------------------------------------------------------------------------------------------------------------------

 <script language=javascript>
     function aa()
     {
       //alert(document.getElementById('ListBox1').value);//获得select第一个被选中的元素       
       //alert(document.getElementById('ListBox1').length)//获得多选框的总元素数目       
       //获得select里所有被选中的元素
       for (var i=0;i<document.getElementById('ListBox1').length;i++)//获得总长度
       {
           if (document.getElementById('ListBox1').options(i).selected) //检测某一元素是否被选中
               alert(document.getElementById('ListBox1').options(i).value);//获得某元素的数值     
       }
     }
   
    </script>

--------------------------------------------------------------------------------------------------------------------------------

<body MS_POSITIONING="GridLayout">
  <form id="Form1" method="post" runat="server">
    
   <asp:button id="Button1" 101; LEFT: 48px; POSITION: absolute; TOP: 128px" runat="server"
    Text="服务器" Width="0px"></asp:button><INPUT 102; LEFT: 12

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: