Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i wanted to pass value from javascript to my aspx page, both are in same page.. the code is

javascript code
C#
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);
    }


C#
alert(value);
document.getElementById('hdnField').value = value;


clientside code for hiddenfield:
<asp:HiddenField ID="hdnField" runat="server" />

serverside code:
C#
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???
Posted
Updated 3-Feb-14 23:03pm
v4
Comments
Nirav Prabtani 4-Feb-14 4:53am    
Have you used master page???
Codes DeCodes 4-Feb-14 4:55am    
yes. i have used it..

use this

JavaScript
document.getElementById('<%= hdnField.ClientID%>').value = value;
 
Share this answer
 
Comments
Codes DeCodes 4-Feb-14 5:14am    
thanks a lot karthik.. it is solved.. lots of thanks to you..
Karthik_Mahalingam 4-Feb-14 5:18am    
Welcome Agustus Jackson :)
Please refer here with your code.

http://forums.asp.net/p/1211504/2139016.aspx[^]
 
Share this answer
 
 
Share this answer
 
Comments
Codes DeCodes 4-Feb-14 5:15am    
thanks for the link jocodes..
JoCodes 4-Feb-14 5:18am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900