jquery给.net 服务端控件赋值 有怎么在后台取值啊 ???
jquery 怎么给HiddenField 赋值, 又怎么在后台取值呢 ??哪位大侠帮帮忙!!! jQuery .NET 控件
[解决办法]
前台:
<script type="text/javascript">
$(document).ready(function () {
$("<%=HfTest.ClientID %>").val("Hello World!");
});
</script>
<asp:HiddenField ID="HfTest" runat="server" />
string val = HfTest.Value;
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="com.easipass.uscm.Web._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
window.onload = function() {
var hfId = '#<%= Hiddenfield1.ClientID%>';
$(hfId).val("测试");
alert($(hfId));
alert($(hfId).val());
};
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:hiddenfield ID="Hiddenfield1" runat="server" ></asp:hiddenfield>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace com.easipass.uscm.Web
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Button1.Text = Hiddenfield1.Value;
}
}
}