62,267
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default6.aspx.cs" Inherits="Default6" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server">
<p>这是Panel1<asp:Button ID="Button1" runat="server" Text="注册"
onclick="Button1_Click" /></p>
</asp:Panel>
<asp:Panel ID="Panel2" runat="server">
<p>这是Panel2</p>
</asp:Panel>
</div>
</form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Default6 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Panel2.Visible = false;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Panel1.Visible = false;
Panel2.Visible = true;
Page.ClientScript.RegisterStartupScript(this.GetType(), "Arthur",
" <script type ='text/javascript'> function test(){window.location = 'Default5.aspx';} setTimeout (test,5000);</script>");
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Register.aspx.cs" Inherits="Register" %>
<!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">
<asp:Panel ID="pOne" runat="server">
<asp:Label ID="lbl" Visible="false" runat="server"></asp:Label>
姓名:<asp:TextBox ID="txtOne" runat="server"></asp:TextBox><br />
密码:<asp:TextBox ID="txtTwo" runat="server"></asp:TextBox><br />
...<br />
<asp:Button ID="btnSubmit" runat="server" Text="注册" OnClick="btnSubmit_Click" />
</asp:Panel>
<asp:Panel ID="pTwo" runat="server" Visible="false" >
<asp:Literal ID="lit" runat="server"></asp:Literal>
</asp:Panel>
</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 Register : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
//一些获取数据保存的操作
...
if (success)
{
lit.Text = "注册成功! 5秒后跳转<script>setTimeout(\"window.location.href='default.aspx'\",5000);</script>";
pTwo.Visible = true;
pOne.Visible = false;
}
else
{
lbl.Visible = true;
lbl.Text = "注册失败! 请重新填写<br><script>setTimeout(\"document.getElementById('" + lbl.ClientID + "').innerText='';\",5000);</script>";
txtTwo.Text = "";
}
}
}