
一个Label
一个textbox控芦档察件,Name为txtPassWord
一个button按钮,Name为btnOK
完整程序如下(程序已经测陪茄试,应该可以满足你的要求)
using System
using System.Collections.Generic
using System.ComponentModel
using System.Data
using System.Drawing
using System.Linq
using System.Text
using System.Windows.Forms
namespace mimachuangti
{
public partial class Form1 : Form
{
int count = 0//记录点击次数
string strpassword = "123"//初始密码
public Form1()
{
InitializeComponent()
}
private void btnOK_Click(object sender, EventArgs e) //按钮响应程序
{
if (txtPassWord.Text == strpassword)
{
MessageBox.Show("欢迎进入")
}
else
{
if (count <2)
{
MessageBox.Show("密码不正确,请重新输入")
txtPassWord.Focus()
count++
}
else
{
MessageBox.Show("输入错误密码超过蠢世三次,系统即将关闭")
this.Close()
}
}
}
}
}
双击确定按钮,转到代码页,加入Response.Redirect(第二张网页)即梁哪凳可<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="确定" /></div>
</form>
</body>
</html>
//第一张网页代码cs后缀
using System
using System.Data
using System.Configuration
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 _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("sure2.aspx")
}
}
//第二张网页代码aspx后缀
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="sure2.aspx.cs" Inherits="sure2" %>
<!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" Text="你已经跳转成功!"></asp:Label></div>
</缓掘form>
</body>
</html>
//第二张网页代码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 sure2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)