Hi Tobater,
1. The example below shows you how to do a postback after get the client side value
- <%@ 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 btnPostBack_Click(object sender, EventArgs e)
- {
-
- lbMessage.Text = "-------------------------page post back--------------------------------";
- }
- </script>
-
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head id="Head1" runat="server">
- <title></title>
- </head>
- <body>
- <form id="form1" runat="server">
- <input type="button" value="getName" onclick="getName()" />
- <input id="name" value="merry" runat="server" />
- <asp:Button ID="btnPostBack" runat="server" Style="visibility: hidden" OnClick="btnPostBack_Click" />
- <asp:Label ID="lbMessage" runat="server"></asp:Label>
- </form>
- </body>
- </html>
-
- <script type="text/javascript">
- function getName() {
- var name=document.getElementById("<%= name.ClientID %>");
- var btnPostBack=document.getElementById("<%= btnPostBack.ClientID %>");
- alert(name.value);
- btnPostBack.click();
-
- }
- </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