ASP.NET页面弹出模式对话框!!

LoginForm.aspx:

ExpandedBlockStart.gif ContractedBlock.gif <% @ Page Language="C#" AutoEventWireup="true" CodeFile="LoginForm.aspx.cs" Inherits="LoginForm"  %>

<! 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" >
ExpandedBlockStart.gifContractedBlock.gif
< style  type ="text/css" >
    #warp
ExpandedSubBlockStart.gifContractedSubBlock.gif    
{}{
      position
: absolute;
      width
:240px;
      height
:200px;
      left
:50%;
      top
:50%;
      margin-left
:-120px;
      margin-top
:-100px;
    
}

ExpandedSubBlockStart.gifContractedSubBlock.gif     
/**//*表格样式*/
    .tableCss 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
{}{
ExpandedSubBlockStart.gifContractedSubBlock.gif     border-collapse
:collapse; /**//* 关键属性:合并表格内外边框(其实表格边框有2px,外面1px,里面还有1px哦) */
ExpandedSubBlockStart.gifContractedSubBlock.gif     border
:solid #6699cc; /**//* 设置边框属性;样式(solid=实线)、颜色(#6699cc) */
ExpandedSubBlockStart.gifContractedSubBlock.gif     border-width
:1px 0 0 1px; /**//* 设置边框状粗细:上 右 下 左 = 对应:1px 0 0 1px */
    
}
 
ExpandedSubBlockStart.gifContractedSubBlock.gif    .tableCss th
{}{border:solid #6699cc;border-width:0 1px 1px 0;padding:2px;}
ExpandedSubBlockStart.gifContractedSubBlock.gif    .tableCss td 
{}{border:solid #6699cc;border-width:0 1px 1px 0;padding:2px;}
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//*按钮样式*/
    .ButtonCss 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
{}{
    font-family
: "Tahoma", "宋体";
    font-size
:9pt; color: #003399;
    border
: 1px #003399 solid;
    color
:006699;
    BORDER-BOTTOM
: #93bee2 1px solid; 
    BORDER-LEFT
: #93bee2 1px solid; 
    BORDER-RIGHT
: #93bee2 1px solid; 
    BORDER-TOP
: #93bee2 1px solid;
    background-image
:url(../images/true.gif);
    background-color
: #e8f4ff;
    CURSOR
: hand;
    font-style
: normal ;
    width
:50px;
    height
:22px;
    
}

    .EditBox
ExpandedSubBlockStart.gifContractedSubBlock.gif    
{}{
        background
: #ffffff; 
        border
: 1px solid #B7B7B7;
        color
: #003366;
        cursor
: text;
        font-family
: "Arial";
        font-size
: 9pt;
        height
: 18px;
        padding
: 1px;
    
}

    
</ style >
    
< base  target ="_self" >
</ head >
< body >
    
< form  id ="form1"  runat ="server" >
    
< div  id ="warp" >
    
< table >
    
< tr >
    
< td >
    
< asp:Label  ID ="labUserName"  runat ="server"  Text ="用户名:" ></ asp:Label >
    
</ td >
    
< td >
    
< asp:TextBox  ID ="txtUserName"  CssClass ="EditBox"  runat ="server" ></ asp:TextBox >
    
< ASP:RequiredFieldValidator  ValidationGroup ="myValidationGroup"  id ="ValidatorUserName"  Runat ="Server"
      ControlToValidate
="txtUserName"
      ErrorMessage
="姓名必须输入"
      Display
="Static"
    
> * </ ASP:RequiredFieldValidator >
    
</ td >
    
</ tr >
    
< tr >
    
< td >
    
< asp:Label  ID ="labPassWord"  runat ="server"  Text ="密码:" ></ asp:Label >
    
</ td >
    
< td >
    
< asp:TextBox  ID ="txtPassWord"  CssClass ="EditBox"  runat ="server" ></ asp:TextBox >
    
< ASP:RequiredFieldValidator  ValidationGroup ="myValidationGroup"  id ="ValidatortxtPassWord"  Runat ="Server"
      ControlToValidate
="txtPassWord"
      ErrorMessage
="密码必须输入"
      Display
="Static"
    
> * </ ASP:RequiredFieldValidator >
    
</ td >
    
</ tr >
    
</ table >
    
< div  style ="text-align: center; height:25px; vertical-align: middle;" >
    
< asp:Button  ID ="btnLogin"  runat ="server"  ValidationGroup ="myValidationGroup"  CssClass ="ButtonCss"  Text ="登录"  OnClick ="btnLogin_Click" />
    
< asp:Button  ID ="btnCancel"  runat ="server"  CssClass ="ButtonCss"  Text ="取消"  OnClick ="btnCancel_Click" />
    
</ div >
    
</ div >
    
</ form >
</ body >
</ html >

后台代码:

 

public partial class LoginForm : System.Web.UI.Page
ExpandedBlockStart.gifContractedBlock.gif
{
    UserLogin userLogin 
= new UserLogin();
    
protected void Page_Load(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
{
    }

    
protected void btnCancel_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
{
        txtPassWord.Text 
= "";
        txtUserName.Text 
= "";
    }

    
protected void btnLogin_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
{
        
string userName = txtUserName.Text.Trim();
        
string passWord = txtPassWord.Text.Trim();
        
int IDValue = userLogin.IDValue(userName, passWord);
        
if (IDValue > 0)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            Session[
"UID"= IDValue;
            Session[
"UserName"= userName;
            Session[
"UserPass"= passWord;
            
//Response.Redirect("Index.aspx", true);//window.opener=null
            
//indow.dialogArguments.location.reload()

              //loginInfo为框架!!
            Response.Write("<script language='javascript'>window.dialogArguments.loginInfo.location.reload();window.close(this);</script>");
            Response.Write();
        }

        
//window.opener.location.reload();
        
//
        
//Response.Write("<script>self.close();</script>");
    }
}

写了个基类:

重载 OnInit(EventArgs e),代码:

 

protected   override   void  OnInit(EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif
{
if (Session["UID"== null)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            Page.RegisterStartupScript(
"""<script language=javascript>alert('你的没有登录!请登录!!');window.showModalDialog('LoginForm.aspx',parent,'dialogWidth:400px;dialogHeight:300px;center:yes;status:no;scroll:yes;help:no;');</script>");
        }

}

然后页面继承基类即可!!

可以判断用户是否登录!!

转载于:https://www.cnblogs.com/yagebuqq/archive/2008/07/22/1248828.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值