国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

寫一個簡單的登陸控件

2024-07-21 02:24:23
字體:
來源:轉載
供稿:網友
login.ascx

由于在頁面上很頻繁使用登陸,把它做成一個控件是很有必要的,下面就是我寫的一個簡單的登陸控件,大家可以根據的需要完善一下。

<%@ import namespace="system.data" %>
<%@ import namespace="system.data.oledb" %>
<script language="vb" runat="server">
sub page_load(sender as object,e as eventargs)
session("accessed")=false
if session("username")="" and not ispasslogin() then
lbllogin.visible=true
lblmessage.visible=false
ispasslogin()
else
lblmessage.text=showprompt(true)
lblmessage.visible=true
lbllogin.visible=false
end if
end sub
'用戶登陸驗證
public function ispasslogin() as boolean
dim myconnection as oledbconnection
dim strconnection as string="provider=microsoft.jet.oledb.4.0; data source=" & server.mappath("database/popmarry.mdb")
myconnection=new oledbconnection(strconnection)
dim sqlcommand="select * from inmember where memberid='" & userid & "'" & " and pwd='" & userpassword & "'"

dim myadapter as new oledbdataadapter(sqlcommand,myconnection)
dim ds as dataset=new dataset()
myadapter.fill(ds,"inmember")
dim dt as datatable=ds.tables("inmember")
if dt.rows.count>0 then
session("username")=userid
return(true)
else
return(false)
end if
end function

'顯示登陸信息
public function showprompt(bolinfo as boolean) as string
if bolinfo then
dim strwelcome as string
strwelcome="<table width='165' cellpadding='3' border='0' align='center'><tr><td align='center'>歡迎您,<font color='#ff0000'>" & session("username") & "</font></td></tr><tr><td align='center'>"
strwelcome &="<table width='150' border='0'><tr><td align='center'>狀態: <font color='#ff3300'>新婚網會員</font></td></tr></table>"
strwelcome &="<table width='110' border='0'><tr><td align='center'>控制面板</td><td align='center'><a onclick='return logoutconfirm()' href='login/logout.aspx'>退出登錄</a></td></tr></table></td></tr></table>"
'返回成功登陸信息
return(strwelcome)
else
dim strerror as string
strerror="<table width='130'align='center'><tr><td>登錄失敗:<br>1.用戶名或密碼錯誤<br>2.此帳號被鎖定<br>3.未<a href='../register/register.asp' target='_blank'>注冊</td></tr>"
strerror &="<tr><td height='20'><center><a href='javascript:onclick=history.go(-1)'>【返回】</a></center></td></tr></td></tr></table>"
'返回登陸失敗信息
return(strerror)
end if
end function

public property userid as string
get
userid=txtuserid.text
end get
set
txtuserid.text=value
end set
end property

'定義userpassword的屬性
public property userpassword as string
get
userpassword=txtuserpassword.text
end get
set
txtuserpassword.text=value
end set
end property
</script>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="168">
<tr>
<td>
<asp:label id="lbllogin" runat="server">
<table width="168" height="60">
<tr>
<td width="63" align="center">用戶名:</td>
<td colspan="2" align="left">
<asp:textbox borderstyle="groove" height="20" width="90px" runat="server" id="txtuserid" />
<asp:requiredfieldvalidator controltovalidate="txtuserid" display="dynamic" id="rfduserid" runat="server" errormessage="<font color=red>*</font>" />
</td>
</tr>
<tr>
<td align="center">密 碼:</td>
<td colspan="2" align="left">
<asp:textbox borderstyle="groove" height="20" width="90px" runat="server" textmode="password" id="txtuserpassword" />
<asp:requiredfieldvalidator controltovalidate="txtuserpassword" display="dynamic" id="rfdpassword" runat="server" errormessage="<font color=red>*</font>" />
</td>
</tr>
<tr align="center">
<td colspan="3"><input name="image" type="image" src=http://www.163design.net/n/i/"images/form_login.gif" width="40" height="18" border="0">
&nbsp; <img src=http://www.163design.net/n/i/"images/form_reg.gif" width="40" height="18" border="0">&nbsp;
<img src=http://www.163design.net/n/i/"images/form_lost.gif" width="60" height="18" border="0"></td>
</tr>
</table>
</asp:label>
<asp:label id="lblmessage" runat="server">
<table width="100%">
<tr>
<td>&nbsp;</td>
</tr>
</table>
</asp:label>
</td>
</tr>
</table>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沙湾县| 博兴县| 莎车县| 通化市| 雅安市| 富平县| 洪湖市| 北流市| 翁牛特旗| 建阳市| 武强县| 汝州市| 嘉义市| 西丰县| 汝州市| 东宁县| 林州市| 清水河县| 巴彦淖尔市| 温州市| 巴马| 禄丰县| 远安县| 昌乐县| 迁安市| 阳信县| 黔江区| 三河市| 张北县| 安阳县| 鹤山市| 荥经县| 龙门县| 丘北县| 奉贤区| 汶上县| 靖宇县| 沈丘县| 久治县| 长沙市| 光山县|