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
- <%@ Page Language="C#" AutoEventWireup="true" %>
-
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
- <script runat="server">
-
- protected void button1_Click(object sender, EventArgs e)
- {
- label1.Text = "src of img1 is: " + hf1.Value;
- }
- </script>
-
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head id="Head1" runat="server">
- <title></title>
- </head>
- <body>
- <form id="form1" runat="server">
- <img src="http://cutesoft.net/utility/anonymous.gif" id="img1" />
- <asp:Button ID="button1" runat="server" Text="Get src in server side" OnClientClick="getSrc()"
- OnClick="button1_Click" /><br />
- <asp:Label ID="label1" runat="server"></asp:Label>
- <asp:HiddenField ID="hf1" runat="server" />
- </form>
- </body>
- </html>
-
- <script>
- function getSrc()
- {
- var img1=document.getElementById("img1");
- var hf1=document.getElementById("<%= hf1.ClientID %>");
- hf1.value=img1.src;
- }
- </script>
Regards,
ken