刚学asp两天遇到一个问题,在vs2005中写的,请各位指教第一个asp form1.aspx 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="form1.aspx.cs" Inherits="WebApplication2.form1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title></head>
<body>
<form action="GetInfo.aspx" runat="server" method="post" id="frm">
<br /> name:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<div> name: <% =Request.QueryString["TextBox1"] %><br />
nameform: <% =Request.Form["TextBox1"] %></div> </form>
</body>
</html>
相应的cs中的代码:
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("GetInfo.aspx");
}第二个asp如下 GetInfo.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetInfo.aspx.cs" Inherits="WebApplication2.GetInfo" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body runat="server">
<center>接收get方法传来的值
<hr />
<%
string name = Request["TextBox1"];
Response.Write("get name is " + name); %>
<br />
name :<%=Request.Form["TextBox1"] %></center>
</body>
</html> 问题: 我不能在第二个页面不得到第一个页面的值,呵呵,向各位请教,我错在哪里了?(注意:如果第一个asp用htm写就不会出问题)
如何才能在第二个页面得到第一个页面的值?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="form1.aspx.cs" Inherits="WebApplication2.form1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title></head>
<body>
<form action="GetInfo.aspx" runat="server" method="post" id="frm">
<br /> name:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<div> name: <% =Request.QueryString["TextBox1"] %><br />
nameform: <% =Request.Form["TextBox1"] %></div> </form>
</body>
</html>
相应的cs中的代码:
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("GetInfo.aspx");
}第二个asp如下 GetInfo.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetInfo.aspx.cs" Inherits="WebApplication2.GetInfo" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body runat="server">
<center>接收get方法传来的值
<hr />
<%
string name = Request["TextBox1"];
Response.Write("get name is " + name); %>
<br />
name :<%=Request.Form["TextBox1"] %></center>
</body>
</html> 问题: 我不能在第二个页面不得到第一个页面的值,呵呵,向各位请教,我错在哪里了?(注意:如果第一个asp用htm写就不会出问题)
如何才能在第二个页面得到第一个页面的值?
解决方案 »
- 如何实现在本窗口打开
- js怎么获取ifame框架里的公共变量或者控件的值??
- 如何在masterPage中的子页中重写 OnInit事件
- 急!急!急!求最简单的bbs的源码(c#)
- 大家好:我在调试电子商务程序的注册会员页面时,竟然相同的用户名可以注册好几次,请问大家是怎么回事情啊?
- 水晶报表无法导出为html,不知何故?100分请教!
- 一个困扰我很久的数据库连接问题
- NPOI选择单元格范围加边框!
- vs2010引用supermap软件引用了dll但设计器还是打不开?
- Server.UrlEncode的问题
- 初学菜鸟散分询问用QueryString传递中文参数的解决方法..
- asp.net 有没有验证输入必须为字符的控件?
去asp版问去吧...不要在.net里写asp....
用session试试
用session试试
<div> name: <% =Request.QueryString[ "TextBox1 "] %> <br />
nameform: <% =Request.Form[ "TextBox1 "] %> </div> </form>
有问题。
不知道你想干什么。
只有在提交到的页面中才可以这么用。
Response.Redirect("accountmassage.aspx?TextBox1='name'");
试试
看上去象是输出植,但有不象,不明白,不明白,textbox1是什么,输出Textbox的植不是这样的吧,讨论,textbox1.text
学习
呵呵,我试了一下,还是老样子,谢谢。2》第一个页面中的:
<div> name: <% =Request.QueryString[ "TextBox1 "] %> <br /> nameform: <% =Request.Form[ "TextBox1 "] %> </div> </form>
有问题。
不知道你想干什么。
只有在提交到的页面中才可以这么用。 呵呵,把它去掉,我也得不到值,这只是一个测试(是因为第二个页面得不到值,我才这么测试的) 谢谢你了。3》name=TextBox1.Text.trim();
Response.Redirect( "accountmassage.aspx?TextBox1= 'name ' "); 这样也不行,不过还是谢谢zhangj1012003_2007的耐心
我知道这个可能很简单,只不过我自己闷头搞了一个星期天都没有答案,书中也没有答案,所以还是请热心你人能给出答案,谢谢了
看上去象是输出植,但有不象,不明白,不明白,textbox1是什么,输出Textbox的植不是这样的吧,讨论,textbox1.text
学习
呵呵,每本书都有这样一个类似的例子,不过是htm-->asp的,我写的是aspx——》aspx的 Request.QueryString和Request.form 都是取值的一种方式,这个也是书中的。
{
Response.Redirect( "GetInfo.aspx ");
}
------------------------------
這行代碼去掉,並把Button1的PostbackUrl設置為GetInfo.aspx.
比如http://XXXXX.com?uid=xuzicn&content=123456xxx,在服务器端执行Request.QueryString(“uid”)就得到xuzicn,Request.QueryString(“content”)就得到123456xxx
谢谢boblaw ,zhangj1012003_2007,阿徐德基罗 , 九月鹰飞 ,谢谢你们,没有你们的热情和耐心我还是不知道答案啊,
我用boblaw的方法解决了问题,看样子有很多东西书本中是学不到的啊!,我刚刚学net,以后还要向各位请教啊,我这就给你们加分去!