两个页面
第一个页面ButtonSearchTyped.aspx
<%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">
public string SearchString
{
get
{
return txtSearch.Text;
}
}
</script><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Button Search Typed</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblSearch" runat="server" Text="Search:"></asp:Label>
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Go!" PostBackUrl="~/ButtonSearchResultsTyped.aspx" />
</div>
</form>
</body>
</html>
第二个页面ButtonSearchResultsTyped
<%@ Page Language="C#" %>
<%@ PreviousPageType VirtualPath="~/ButtonSearchTyped.aspx" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e)
{
if (PreviousPage != null)
{
lblSearch.Text = string.Format("Search For: {0}", PreviousPage.SearchString);
}
}
</script><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Button Search Results Typed</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblSearch" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
问题是:第二个页面里的
protected void Page_Load(object sender, EventArgs e)
{
if (PreviousPage != null)
{
lblSearch.Text = string.Format("Search For: {0}", PreviousPage.SearchString);
}
它为什么说我的PreviousPage.SearchString没有被定义?????
第一个页面ButtonSearchTyped.aspx
<%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">
public string SearchString
{
get
{
return txtSearch.Text;
}
}
</script><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Button Search Typed</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblSearch" runat="server" Text="Search:"></asp:Label>
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Go!" PostBackUrl="~/ButtonSearchResultsTyped.aspx" />
</div>
</form>
</body>
</html>
第二个页面ButtonSearchResultsTyped
<%@ Page Language="C#" %>
<%@ PreviousPageType VirtualPath="~/ButtonSearchTyped.aspx" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e)
{
if (PreviousPage != null)
{
lblSearch.Text = string.Format("Search For: {0}", PreviousPage.SearchString);
}
}
</script><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Button Search Results Typed</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblSearch" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
问题是:第二个页面里的
protected void Page_Load(object sender, EventArgs e)
{
if (PreviousPage != null)
{
lblSearch.Text = string.Format("Search For: {0}", PreviousPage.SearchString);
}
它为什么说我的PreviousPage.SearchString没有被定义?????
解决方案 »
- ASP.NET 百度图片效果或者QQ相册效果怎么实现?
- 在GridView的FooterRow中如何使用onclick事件?
- 在datalist中不使用数据绑定,而在DataList1_ItemDataBound中取得每行数据后在给datalist中的控件赋值?
- 后台调用前台的方法
- 请教一个跨服务器导入MDB的存储过程的问题?
- 同一个问题-第三贴-已经知道路径,判断某个文件夹里面是否有对应这个路径的图片?
- 有什么办法可以设置某ActiveX控件在IE中始终信任。
- 重开贴:如何控制客户端打印时为横向,A4纸,急..................
- 哪位好心大哥帮帮忙啊~~!呜呜呜~急死了~!TreeView问题~!
- 做了一个函数,重载其中的方法 3 个,本地机可以用,但服务器上只有 2 个可用。为什么,最后一个是后来增加的。怎么处理呀
- 调用JS函数问题
- DropDownList如何取节点ID
如果没有这个指令 PreviousPage属性会把前页面作为通用的Page类的实例返回