javascript检测。在回送

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

<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">
   &nbsp;
   <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: 128px; position: absolute; top: 128px" onclick="aa()"
    type="button" value="客户端">
   <asp:label id="label1" style="z-index: 103; left: 40px; position: absolute; top: 184px" runat="server"
    width="184px" height="80px">label</asp:label><input id="aa1" style="z-index: 104; left: 40px; position: absolute; top: 72px" type="text">&nbsp;
   <asp:textbox id="textbox1" style="z-index: 105; left: 40px; position: absolute; top: 128px" runat="server"
    width="0px"></asp:textbox><asp:label id="label2" style="z-index: 106; left: 416px; position: absolute; top: 80px" runat="server"
    width="272px" height="144px"></asp:label></form>
  <script language="javascript">
   function aa()
   {    
     alert("客户端触发事件");    
     var aaaa=document.all.aa1.value; //获得客户端元素的数值    
     document.getelementbyid('textbox1').value=aaaa; //把客户端元素的数值保留入服务器端元素内     
     //alert(document.getelementbyid('textbox1').value);//显示服务器端元素的数值 
     document.getelementbyid('button1').click();//使用脚本回送页面    
   }
  
  </script>
 </body>

< <script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
阅读更多
个人分类: javascript
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭