如何将值从Javascript传递到Aspx页面 [英] How Do I Pass Values From Javascript To Aspx Page
问题描述
我想将值从javascript传递到我的aspx页面,两者都在同一页面..代码是
javascript代码
var OpenPopup = function(){
alert( value);
var value = window.showModalDialog( PopUp.aspx,' popup' , dialogHeight:15; dialogWidth:20; center:yes; toolbar:false; status:0;滚动:0;缦:0;帮助:无跨度>);
alert( value );
alert(document.getElementById(' hdnField')。 value = value );
alert( value );
}
alert( value < /跨度>);
document.getElementById(' hdnField')。 value = value ;
hiddenfield的客户端代码:
< asp:HiddenField ID =hdnFieldrunat =server/>
服务器代码:
protected void Button1_Click( object sender,EventArgs e)
{
string name = Request.Form [ hdnField];
string aa = hdnField.Value.ToString();
}
$ j $ b执行javascript后,我点击按钮查看值存储在hdnfield bt中它返回null值...也。在javascript警报显示输出直到第二警报..当警报进入第3警报它停止显示第3和第4警报..有什么我缺少???
使用这个
document .getElementById(' <%= hdnField.ClientID%>')。value = value;
请在此处参考您的代码。
http://forums.asp.net/p/1211504/2139016.aspx [ ^ ]
参考
http://www.jigar.net/howdoi/viewhtmlcontent336.aspx [ ^ ]
i wanted to pass value from javascript to my aspx page, both are in same page.. the code is
javascript code
var OpenPopup = function () {
alert("value");
var value = window.showModalDialog("PopUp.aspx", 'popup', "dialogHeight:15; dialogWidth:20; center:yes;toolbar: false;status: 0;scroll:0;unadorned:0;help:no");
alert(value);
alert(document.getElementById('hdnField').value = value);
alert(value);
}
alert(value);
document.getElementById('hdnField').value = value;
clientside code for hiddenfield:
<asp:HiddenField ID="hdnField" runat="server" />
serverside code:
protected void Button1_Click(object sender, EventArgs e)
{
string name = Request.Form["hdnField"];
string aa = hdnField.Value.ToString();
}
after the javascript is executed, i clicked on a button to check value stored in hdnfield bt it returns null value... also. in javascript alert shows output till 2nd alert.. as alert goes into 3rd alert it stops showing 3rd and 4th alert.. is there anything i am missing???
use this
document.getElementById('<%= hdnField.ClientID%>').value = value;
Please refer here with your code.
http://forums.asp.net/p/1211504/2139016.aspx[^]
Refer
http://www.jigar.net/howdoi/viewhtmlcontent336.aspx[^]
这篇关于如何将值从Javascript传递到Aspx页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!