页面传值问题大家帮帮我啊!!!!!1

圣诞老人123 2008-03-05 11:30:10
请高手来帮帮小弟我啊不胜感激!!!!!!!!!!

页面一:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Buttom的各种特性1.aspx.cs" Inherits="Buttom的各种特性" %>

<!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>
<script language="javascript" type="text/javascript">
function He()
{
alert("hello Asp.net");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="显示D1" OnCommand="Button_Command" CommandName="Do1" OnClientClick="He()" /> <asp:Button ID="Button2"
runat="server" Text="显示D2" OnCommand="Button_Command" CommandName="Do2" /><br />
<br />
<asp:Button ID="Button3" runat="server" Text="Button" PostBackUrl="~/Buttom的各种特性2.aspx" OnClick="Button3_Click"/></div>
</form>
</body>
</html>
页面一后台:
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 Buttom的各种特性 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button_Command(Object sender, System.Web.UI.WebControls.CommandEventArgs e)
{
switch (e.CommandName)
{
case("Do1"):
Response.Write("Do1");
break;
case("Do2"):
Response.Write("Do2");
break;
}
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.Redirect("Buttom的各种特性2.aspx");
}
}
//这里演示了Buutton的功能COMMAND和OnClientClick,PostBackUrl
页面2前台:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Buttom的各种特性2.aspx.cs" Inherits="Buttom的各种特性2" %>

<!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:Label ID="Label1" runat="server"></asp:Label><br />
<br />
<asp:Label ID="Label2" runat="server"></asp:Label> </div>
</form>
</body>
</html>
页面2后台:
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 Buttom的各种特性2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button pp_Bt1;
Button pp_Bt2;
pp_Bt1 = (Button)PreviousPage.FindControl("Button1");
pp_Bt2 = (Button)PreviousPage.FindControl("Button2");
Label1.Text = pp_Bt1.Text;
Label2.Text = pp_Bt2.Text;

}
}
...全文
36 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
panzi667 2008-03-05
  • 打赏
  • 举报
回复
什么问题?

110,561

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧