Re: Enumerate html tag elements in custom dialog; server-side?

  •  11-08-2010, 7:45 PM

    Re: Enumerate html tag elements in custom dialog; server-side?

    Hi Tobater,
     
    1. The example below shows you how to do a postback after get the client side value
    1. <%@ Page Language="C#" AutoEventWireup="true" %>  
    2.   
    3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    4.   
    5. <script runat="server">  
    6.   
    7.    
    8.     protected void btnPostBack_Click(object sender, EventArgs e)  
    9.     {  
    10.         //postback here and implement your own logic  
    11.         lbMessage.Text = "-------------------------page post back--------------------------------";  
    12.     }  
    13. </script>  
    14.   
    15. <html xmlns="http://www.w3.org/1999/xhtml">  
    16. <head id="Head1" runat="server">  
    17.     <title></title>  
    18. </head>  
    19. <body>  
    20.     <form id="form1" runat="server">  
    21.         <input type="button" value="getName" onclick="getName()" />  
    22.         <input id="name" value="merry" runat="server" />  
    23.         <asp:Button ID="btnPostBack" runat="server" Style="visibility: hidden" OnClick="btnPostBack_Click" />  
    24.         <asp:Label ID="lbMessage" runat="server"></asp:Label>  
    25.     </form>  
    26. </body>  
    27. </html>  
    28.   
    29. <script type="text/javascript">  
    30. function getName() {  
    31.  var name=document.getElementById("<%= name.ClientID %>");  
    32.  var btnPostBack=document.getElementById("<%= btnPostBack.ClientID %>");  
    33.  alert(name.value);  
    34.  btnPostBack.click();  
    35.    
    36. }  
    37. </script> 
    2. If you want to get the control which contains "runat=server" on client side, should use the format below
     
    <input id="name" value="merry" runat="server" />
     
     var name=document.getElementById("<%= name.ClientID %>");
     
     
    Regards,
     
    ken
     
     
     
View Complete Thread