javascript檢測。在回送

來源:互聯網
上載者:User

<body MS_POSITIONING="GridLayout">
  <form id="Form1" method="post" runat="server">  
   <asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 192px" runat="server"
    Text="伺服器1"></asp:Button>  
   <asp:TextBox id="TextBox1" style="Z-INDEX: 102; LEFT: 16px; POSITION: absolute; TOP: 24px" runat="server"
    Height="144px" Width="280px" TextMode="MultiLine"></asp:TextBox>
   <asp:Label id="Label1" style="Z-INDEX: 103; LEFT: 32px; POSITION: absolute; TOP: 248px" runat="server"
    Height="96px" Width="248px">Label</asp:Label>
   <INPUT style="Z-INDEX: 104; LEFT: 192px; POSITION: absolute; TOP: 192px" type="button"
    value="客戶" id="bt11" onclick="aa();">
   <asp:Button id="Button2" style="Z-INDEX: 105; LEFT: 104px; POSITION: absolute; TOP: 192px" runat="server"
    Text="伺服器2"></asp:Button>
   <asp:Label id="Label2" style="Z-INDEX: 106; LEFT: 312px; POSITION: absolute; TOP: 248px" runat="server"
    Width="208px" Height="88px">Label</asp:Label>
   <asp:HyperLink id="HyperLink1" style="Z-INDEX: 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" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 128px" runat="server"
    Text="伺服器" Width="0px"></asp:button><INPUT style="Z-INDEX: 102; LEFT: 12



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.