将值从javascript传递到aspx页面

问题描述:

hi ..
我有两个页面,一个是HTML,另一个是aspx.我需要将使用javascript的html页面的值传递给aspx页面.我已经在getElementByid方法中尝试过,但是它仅传递null值.该代码是

hi..
i have two pages one is HTML and other one is aspx. i need to pass a value from html page using javascript to aspx page. i already tried in getElementByid method but it passing null value only. that code is

function call()
{
var value = getQuerystring('queryvalue');
var value1= "'true'";
var str="www.mcamdois.com/sitemap.htm";
  document.getElementById("Hidden1").value=str;
//alert(value)
//alert(value1);
if(value!=value1)
{
window.location='Default5.aspx';
value="'true'";
}
else
{
return true;
}
return true
}

您不能像在Windows窗体中那样仅引用页面之间的传递值.考虑一下网络的本质.根据请求将页面提供给浏览器.如果需要在HTML和ASP.NET页面之间传递值,则需要使用查询字符串,以便将数据与请求一起传递.
You can''t just reference a page a pass values between them like you would a Windows form. Think about the nature of the web. Pages are served to a browser based on a request. If you need to pass values between HTML and ASP.NET pages you will need to use a querystring so the data is passed along with the request.


1)编写window.location ='' Default5.aspx?param =''+值;

2)在Default5页面中,编写以下代码以获取页面加载中的值.
1) Write window.location=''Default5.aspx?param='' + value;

2) In the Default5 page, write the following code to get the value in the page load.
if(null != Request.QueryString["param"])
{
    string mstrParamValue = Request.QueryString["param"];
}