给它的Click事件绑定一个处理程序,那所这个程序什么也不做,该页也会被回发。

解决方案 »

  1.   

    to webdiyer(webdiyer)
    曾经能刷新,但现在不行了
      

  2.   

    正好我做了一个login的pagelet
    页面文件
    <%@ Control Language="c#" AutoEventWireup="false" Codebehind="Login.ascx.cs" Inherits="corun.Controls.Login" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
    <p align="center"><asp:Label id="Lab_CopyRight" runat="server">版权所有&copy;&nbsp;2001&nbsp;广州市百成科技有限公司</asp:Label></p>
    <p align="center">
    <asp:panel id="PHLogined" Runat="server" Visible="False">工号 
    <asp:TextBox id="tb_UserName" Runat="server" BackColor="Control" BorderWidth="1px" Height="20px" Width="40"></asp:TextBox>密码 
    <asp:TextBox id="tb_Password" Runat="server" BackColor="Control" BorderWidth="1px" Height="20px" Width="40" TextMode="Password"></asp:TextBox>
    <asp:Button id="btn_Login" Runat="server" BorderWidth="1px" Height="20px" Width="40px" text="登录"></asp:Button></asp:panel>
    <asp:panel id="PHLogin" Runat="server" Visible="False">姓名 
    <asp:Label id="lab_UserName" Runat="server"></asp:Label>部门 
    <asp:Label id="lab_Depart" Runat="server"></asp:Label>用户群组 
    <asp:Label id="Lab_Group" Runat="server"></asp:Label>
    <asp:Button id="btn_Logout" BorderWidth="1px" Height="20px" Width="40px" Text="退出" runat="server"></asp:Button>
    </asp:panel>
    </p>
    <p align="center"><a href="mailto:[email protected]">mailto:[email protected]</a></p>代码文件
    namespace corun.Controls
    {
    using System;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls; /// <summary>
    /// Login 的摘要说明。
    /// </summary>
    public abstract class Login : System.Web.UI.UserControl
    {
    protected System.Web.UI.WebControls.TextBox tb_UserName;
    protected System.Web.UI.WebControls.TextBox tb_Password;
    protected System.Web.UI.WebControls.Panel PHLogined;
    protected System.Web.UI.WebControls.Label lab_UserName;
    protected System.Web.UI.WebControls.Label lab_Depart;
    protected System.Web.UI.WebControls.Label Lab_Group;
    protected System.Web.UI.WebControls.Button btn_Login;
    protected System.Web.UI.WebControls.Button btn_Logout;
    protected System.Web.UI.WebControls.Label Lab_CopyRight;
    protected System.Web.UI.WebControls.Panel PHLogin; private void InitUserInfo(){
    try
    {
    //如果Session["UserInfo为空或不是对象"]认为没有登录
    if(Session["UserInfo"] is corun.CorunClass.BaseUserInfo)
    {
    this.PHLogined.Visible=false;
    this.PHLogin.Visible=true;
    corun.CorunClass.BaseUserInfo UInfo=(corun.CorunClass.BaseUserInfo)Session["UserInfo"];
    this.lab_Depart.Text=UInfo.strDepartName;
    this.Lab_Group.Text=UInfo.strGroupName;
    this.lab_UserName.Text =UInfo.strUserName;
    }
    else
    {
    this.PHLogined.Visible=true;
    this.PHLogin.Visible=false;
    }
    }
    catch(System.Exception excep){
    Response.Write (corun.CorunClass.Validate.jsAlert(excep.Message));
    }
    }
    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    if(!Page.IsPostBack){InitUserInfo();}
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// 设计器支持所需的方法 - 不要使用
    /// 代码编辑器修改此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.btn_Login.Click += new System.EventHandler(this.btn_Login_Click);
    this.btn_Logout.Click += new System.EventHandler(this.btn_Logout_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion
    private void btn_Logout_Click(object sender, System.EventArgs e)
    {
    Session["UserInfo"]=null;
    this.InitUserInfo();
    //Response.Redirect(System.Configuration.ConfigurationSettings.AppSettings["BaseURL"].ToString()+"Login.aspx",true);
    } private void btn_Login_Click(object sender, System.EventArgs e)
    {
    try{
    string strUserName=this.tb_UserName.Text.Trim();
    string strPassword=this.tb_Password.Text.Trim();
    Session["UserInfo"]=corun.CorunClass.UserInfo.UserLogin(strUserName,strPassword);
    this.InitUserInfo();
    }
    catch(System.Exception excep){
    Response.Write(corun.CorunClass.Validate.jsAlert(excep.Message));
    }
    }
    }
    }