PostBackUrl怎么用啊
ResultPage.aspx
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "ResultPage.aspx.cs " Inherits= "ResultPage " %>
<!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 id= "form1 " runat= "server ">
<div>
<asp:TextBox ID= "TextBox1 " runat= "server "> </asp:TextBox>
<asp:Label ID= "labelResult " runat= "server " Text= "Label "> </asp:Label>
<asp:Button ID= "Button1 " runat= "server " Text= "Button " PostBackUrl= "~/ResultPage.aspx " OnClick= "Button1_Click " />
</div>
</form>
</body>
</html>
ResultPage.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class ResultPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
labelResult.Text = ((TextBox)PreviousPage.FindControl( "TextBox1 ")).Text;
}
catch
{
labelResult.Text = "????????? ";
}
}
}
怎么无论文本框填什么都是 "????????? "呢
------解决方案--------------------页首加上: <% @previousPageType virtualPath= "~/source.aspx "%>
source.aspx换成来源页地址
------解决方案--------------------另外要在来源页button的PostBackUrl属性加入ResultPage.aspx
地址
------解决方案--------------------PostBackUrl 是为了解决1.1中只能一个SERVER FORM还不能修改ACTION的问题加入的
为了让PostBackUrl能识别POST页的控件,所以需要你指定previousPage页