function callApp() {
var str = $("#<%=txtAccount.ClientID %>").val();
var pwd = $("#<%=txtPwd.ClientID %>").val();
var obj;
$.post("../Handler/ValidateHandler.ashx", { account: str }, function (data, status) {
if (status == "success") {
if ($.trim(data).toLowerCase() == "false") {
obj = document.getElementById("MyFlexApp").flexFun(str);
alert("obj:" + obj);
$("#<%=hidAccount.ClientID %>").val(obj);//obj值存在,但是给隐藏域之后,我在.cs获取hidAccount的值,却获取不到
}
}
});
}
不用使用hidAccount.Value来获取,要使用Request.Form["hidAccount"]来获取提交的js赋值的内容,使用hidAccount.Value需要使用viewstate的,js设置的内容没有更新viewstate,所以获取不到$("#<%=btnRegister.ClientID %>").click(function () {
var account = $("#<%=txtAccount.ClientID %>").val();
var pwd = $("#<%=txtPwd.ClientID %>").val();
if (account.length == 0) {
$("#spErr").text("请输入用户名!");
return false;
}
if (pwd.length == 0) {
$("#spErr").text("请输入密码!");
return false;
}
callApp();
}); function callApp() {
var str = $("#<%=txtAccount.ClientID %>").val();
var pwd = $("#<%=txtPwd.ClientID %>").val();
$.post("../Handler/ValidateHandler.ashx", { account: str }, function (data, status) {
if (status == "success") {
if ($.trim(data).toLowerCase() == "false") {
var result = document.getElementById("MyFlexApp").flexFun(str);
$("#<%=hidAccount.ClientID %>").val(result);
}
}
});
}
function callApp() {
var result;
var str = $("#<%=txtAccount.ClientID %>").val();
var pwd = $("#<%=txtPwd.ClientID %>").val();
$.post("../Handler/ValidateHandler.ashx", { account: str }, function (data, status) {
if (status == "success") {
if ($.trim(data).toLowerCase() == "false") {
result = document.getElementById("MyFlexApp").flexFun(str);
}
}
});
alert(result);//弹出undefined, 但是 弹出框之后,点击确定, 赋值却成功了
$("#<%=hidAccount.ClientID %>").val(result);
}
{
TestMembers member = new TestMembers();
if (!member.Validate(txtAccount.Text))
{
member.Account = txtAccount.Text;
member.Password = EncryptionHelper.MD5(txtPwd.Text);
member.RegisterTime = DateTime.Now; member.Add();
AddLog();
PrintMessage.PrintClientMessage(Page, "恭喜您,注册成功!");
}
else {
PrintMessage.PrintClientMessage(Page, "用户名已存在!");
}
} private void AddLog() {
TestMemberLog memberLog = new TestMemberLog();
memberLog.Account = txtAccount.Text;
memberLog.AccountCookie = Request.Form["hidAccount"]; //hidAccount.Value
memberLog.LogTime = DateTime.Now; memberLog.Add();
}
var result;
var str = $("#<%=txtAccount.ClientID %>").val();
var pwd = $("#<%=txtPwd.ClientID %>").val();
/*$.post("../Handler/ValidateHandler.ashx", { account: str }, function (data, status) {
if (status == "success") {
if ($.trim(data).toLowerCase() == "false") {
result = document.getElementById("MyFlexApp").flexFun(str);
}
}
});*/
$.ajax({
url:"../Handler/ValidateHandler.ashx"
,async:false///////////同步
data:{ account: str },
success:function (data, status) {
if (status == "success") {
if ($.trim(data).toLowerCase() == "false") {
result = document.getElementById("MyFlexApp").flexFun(str);
}
}
}
});
alert(result);//弹出undefined, 但是 弹出框之后,点击确定, 赋值却成功了
$("#<%=hidAccount.ClientID %>").val(result);
}没见你提交hidAccount这个控件的代码啊,动态页肯定获取不到了。。