Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to pass data from aspx page to html page in asp.net.anyone can give this solution
Posted

Hi,

you can pass data from aspx page to html page in method like GET

Let me show you sample code for that

C#
Response.Redirect("testing.htm?val1=murali");


And testing.htm page has following code

HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script language ="javascript" >
   
function GetParam(name) {

  var start=location.search.indexOf("?"+name+"=");
  if (start<0) start=location.search.indexOf("&"+name+"=");
  if (start<0) return '';
  start += name.length+2;
  var end=location.search.indexOf("&",start)-1;
  if (end<0) end=location.search.length;
  var result='';
  for(var i=start;i<=end;i++) {
    var c=location.search.charAt(i);
    result=result+(c=='+'?' ':c);
  }
  return unescape(result);
}

function f1() {
    document.getElementById("resdiv").innerHTML = GetParam('val1');
}
</script> 
    
</head>
<body onload ="f1()">
<div id="resdiv"></div>

</body>
</html>


you can pass values by using above code

All the Best
 
Share this answer
 
Comments
Amir Mahfoozi 16-Oct-11 7:34am    
You're right ! +5
Kishor Khatri 2-Jun-16 5:58am    
Thank You Muralikrishna8811, i was also facing same issue, Thank You :)
You can't access the variable that are local to the page, they need to made public.

Accessing the properties defined in the code-behind your HTML you need to define your properties or variables as public, and then call like this...

<%= this.MyVariable %>


You could also use Literals.
In the ASP Part use...
<asp:literalcontrol runat="server" id="LiteralControl" xmlns:asp="#unknown">

And in the code behind use...
LiteralControl.Text = "<table><tr>...etc";</tr></table>


Hope this helps.
 
Share this answer
 
v2

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