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

  •  11-02-2010, 11:12 PM

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

    Hi Tobster,
     
    If you want to put the value to server side from client side, please try passing through asp:HiddenField. Like the example below
     
    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.     protected void button1_Click(object sender, EventArgs e)  
    8.     {  
    9.         label1.Text = "src of img1 is: " + hf1.Value;  
    10.     }  
    11. </script>  
    12.   
    13. <html xmlns="http://www.w3.org/1999/xhtml">  
    14. <head id="Head1" runat="server">  
    15.     <title></title>  
    16. </head>  
    17. <body>  
    18.     <form id="form1" runat="server">  
    19.         <img src="http://cutesoft.net/utility/anonymous.gif" id="img1" />  
    20.         <asp:Button ID="button1" runat="server" Text="Get src in server side" OnClientClick="getSrc()"  
    21.             OnClick="button1_Click" /><br />  
    22.         <asp:Label ID="label1" runat="server"></asp:Label>  
    23.         <asp:HiddenField ID="hf1" runat="server" />  
    24.     </form>  
    25. </body>  
    26. </html>  
    27.   
    28. <script>  
    29. function getSrc()  
    30. {  
    31.     var img1=document.getElementById("img1");  
    32.     var hf1=document.getElementById("<%= hf1.ClientID %>");  
    33.     hf1.value=img1.src;  
    34. }  
    35. </script>  
     Regards,
     
    ken 
View Complete Thread