how can I get the value of hidden field in my code behind?
I have tried getting it using javascript, but I want to do it in code behind so I can use it when I pass the value on the other page.
function load() {
var lblAddress = document.getElementById("hdnAddress").value;
var lblName = document.getElementById("hdnName").value;
var lblEmail = document.getElementById("hdnEmail").value;
var lblPhone = document.getElementById("hdnPhone").value;
var lblMsg = document.getElementById("hdnMsg").value;
window.parent.document.getElementById("lblAddress").innerText = lblAddress;
window.parent.document.getElementById("lblName").innerText = lblName;
window.parent.document.getElementById("lblEmail").innerText = lblEmail;
window.parent.document.getElementById("lblPhone").innerText = lblPhone;
window.parent.document.getElementById("lblMsg").innerText = lblMsg;
// alert(lblAddress);
}
NOTE:
The flow of this is:
The Page2 is placed on the iframe inside Page1.
You could use query parameters when loading the page that goes into the iframe. Something like this:
function load() {
var lblAddress = document.getElementById("hdnAddress").value;
var lblName = document.getElementById("hdnName").value;
var lblEmail = document.getElementById("hdnEmail").value;
var lblPhone = document.getElementById("hdnPhone").value;
var lblMsg = document.getElementById("hdnMsg").value;
var iframe = document.getElementById("myIframe");
iframe.src = 'Page2.aspx?address=' + encodeURIComponent(lblAddress)
+ '&name=' + encodeURIComponent(lblName)
+ '&email=' + encodeURIComponent(lblEmail)
+ '&phone=' + encodeURIComponent(lblPhone)
+ '&msg=' + encodeURIComponent(lblMsg);
}
Be sure to use encodeURIComponent
when building the URL to avoid injection attacks.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.