如何将数据从ASPX页面传递到HTML页面 [英] How to pass data from aspx page to html page

查看:92
本文介绍了如何将数据从ASPX页面传递到HTML页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将数据从aspx.net中的aspx页传递到html页.任何人都可以提供此解决方案

I want to pass data from aspx page to html page in asp.net.anyone can give this solution

推荐答案

您好,

您可以使用GET
之类的方法将数据从aspx页传递到html页
让我为您展示示例代码

Hi,

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

Let me show you sample code for that

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



并且testing.htm页面具有以下代码



And testing.htm page has following code

<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>



您可以使用上面的代码传递值

所有Best



you can pass values by using above code

All the Best


您无法访问页面本地变量,需要将其公开.

访问HTML背后的代码中定义的属性,您需要将属性或变量定义为public,然后像这样调用...

<%= this.MyVariable %>


您还可以使用Literals.
在ASP部分中使用...
<asp:literalcontrol runat="server" id="LiteralControl" xmlns:asp="#unknown">

并在后面的代码中使用...
LiteralControl.Text = "<table><tr>...etc";</tr></table>


希望这会有所帮助.
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.


这篇关于如何将数据从ASPX页面传递到HTML页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆