| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 861 人关注过本帖
标题:[求助]ASP.NET里global.asax.cs里的代码怎么写?
只看楼主 加入收藏
yhf012
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-4-22
收藏
 问题点数:0 回复次数:1 
[求助]ASP.NET里global.asax.cs里的代码怎么写?
包含用户控件页面的前台代码index.aspx:
<%@ Register TagPrefix="Acme" TagName="Log" Src="login.ascx"%>
<Acme:Log runat="server" id="log"></Acme:Log>
包含用户控件页面的后台代码index.aspx.cs:
namespace nhh_aspnet
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected WebUserControl1 userControl1=new nhh_aspnet.WebUserControl1();

private void Page_Load(object sender, System.EventArgs e)
{

}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
this.userControl1.Click += new System.EventHandler(this.userControl1_Click);

}
#endregion
private void userControl1_Click(object sender, System.EventArgs e)
{
Response.Redirect ("user_index.aspx");
}
}
}
用户控件前台代码login.ascx:
<asp:Button Runat="server" ID="submitBT" EnableViewState="False" Text="登 陆"></asp:Button>
用户控件后代代码login.ascx.cs:
namespace nhh_aspnet
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.SessionState;

/// <summary>
/// WebUserControl1 的摘要说明。
/// </summary>
///

public class WebUserControl1 : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.Button submitBT;
public event System.EventHandler Click;

private void Page_Load(object sender, System.EventArgs e)
{

}
private void InitializeComponent()
{
this.submitBT.Click += new System.EventHandler(this.submitBT_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
private void submitBT_Click(object sender, System.EventArgs e)
{
if (Click!=null)
{
Click(this,new EventArgs());
}
}
}
}

现在的问题是我点击“登陆”按钮不能转到我要去的页面,请教高手指点,,要怎么写代码才能实现我的要求。。。请各位大虾多多指点指点,,小弟好着急。。。。
搜索更多相关主题的帖子: NET asax global ASP 代码 
2006-05-01 17:38
小笨笨
Rank: 5Rank: 5
等 级:贵宾
威 望:19
帖 子:1169
专家分:0
注 册:2006-4-17
收藏
得分:0 

看你上面的代码,与global文件无关吧?

在你的Page_Load里加上

if (!this.ispostback)
{}


欢迎光临我的博客: http://smallfools.blog./default.html
2006-05-01 19:18
快速回复:[求助]ASP.NET里global.asax.cs里的代码怎么写?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015547 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved