利用js 调用后台写的方法
1 <script src="js/jquery-1.7.1.min.js"></script> 2 2 <script> 3 3 $(function () { 4 4 $(".btn").click(function () { 5 5 $("#txtname").val('<%=Session["Name"]%>'); 6 6 $("#txtdate").val('<%=GetDate()%>'); 7 7 $("#txtnum").val('<%=GetNum()%>'); 8 8 }); 9 9 }); 10 10 </script> 11 11 12 12 13 13 14 14 15 15 <body> 16 16 <form id="form1" runat="server"> 17 17 <div> 18 18 <asp:TextBox ID="txtname" runat="server"></asp:TextBox><br /> 19 19 <asp:TextBox ID="txtdate" runat="server"></asp:TextBox><br /> 20 20 <asp:TextBox ID="txtnum" runat="server"></asp:TextBox> 21 21 <input type="button" class="btn" value="提交" /> 22 22 </div> 23 23 </form> 24 24 </body>