当前位置:编程学习 > C#/ASP.NET >>

急急!!求一个ASP.NET Web程序代码.

创建一个ASP.NET Web程序,它包含两个网页,其中一个代码中包含一个服务器空间button,用户单击button控件,IE将打开第二个网页的具体代码
答案:楼上两位把单词写错了。都说的对,第二位详细些,呵呵。
应该是Response.Redirect("第二个网页.aspx"); 
少了个字母t。
其他:button 里面写Response.Redirec("*.aspx"); 双击这个Buttox控件
在代码里写
 Response.Redirec("第二个网页.aspx"); 第一个页面:
<%@ 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" Text="Button" OnClick="Button1_Click" /></div>
    </form>
</body>
</html>
代码部分:
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("Default2.aspx"); 
    }
}
第二个页面:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!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>
    
    </div>
    </form>
</body>
</html> 

上一个:asp.net应用程序中的服务器错误帮忙解决一下啊
下一个:Asp.Net程序中的三层如何划分?每层包含哪些组件和模块?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,