伺服器控制項之使用者登入

2021-04-01 05:18:55 字數 4759 閱讀 9028

using system;

using system.web.ui;

using system.web.ui.webcontrols;

using system.collections.specialized;

using system.***ponentmodel;

using system.drawing;

using system.globalization;

namespace webframe

remove

}public event eventhandler loginout

remove

}#endregion

#region 定義ipostbackdatahandler與ipostbackeventhandler的方法

bool ipostbackdatahandler.loadpostdata(string postdatakey,namevaluecollection values)

string buttonout = values[this.outbuttonname];

bool buttonoutclick = (buttonout!=null)&&(buttonout.length!=0);

if(buttonoutclick)

return false;

}void ipostbackdatahandler.raisepostdatachangedevent()

protected virtual void onlogin(eventargs e)

#endregion

#region 將控制項加入頁面時發生

protected override void onprerender(eventargs e)

#endregion

#region 定義控制項屬性

public virtual string userlabeltext

set}

public virtual string passwordlabeltext

set}

public string userinputid

}public string userinputname

}public string username

}public string passwordinputid

}public string passwordinputname

}public string password

}public string inbuttonid

}public string inbuttonname

}public virtual string inbuttontext

set

}public string outbuttonid

}public string outbuttonname

}public virtual string outbuttontext

set}

#endregion

#region 控制項輸出

protected override void render(htmltextwriter writer)

if(!bordercolor.isempty)

if((borderstyle != borderstyle.none) && (borderstyle != borderstyle.notset))

if(!borderwidth.isempty)

writer.addattribute(htmltextwriterattribute.border,"1");

writer.renderbegintag(htmltextwritertag.table);

writer.renderbegintag(htmltextwritertag.tr);

writer.renderbegintag(htmltextwritertag.td);

writer.write(this.userlabeltext);

writer.renderendtag();

writer.renderbegintag(htmltextwritertag.td);

writer.addattribute(htmltextwriterattribute.type,"text");

writer.addattribute(htmltextwriterattribute.id,this.userinputid);

writer.addattribute(htmltextwriterattribute.name,this.userinputname);

writer.addattribute(htmltextwriterattribute.value,string.empty);

writer.renderbegintag(htmltextwritertag.input);

writer.renderendtag();

writer.renderendtag();

writer.renderendtag();

writer.renderbegintag(htmltextwritertag.tr);

writer.renderbegintag(htmltextwritertag.td);

writer.write(this.passwordlabeltext);

writer.renderendtag();

writer.renderbegintag(htmltextwritertag.td);

writer.addattribute(htmltextwriterattribute.type,"password");

writer.addattribute(htmltextwriterattribute.id,this.passwordinputid);

writer.addattribute(htmltextwriterattribute.name,this.passwordinputname);

writer.addattribute(htmltextwriterattribute.value,string.empty);

writer.renderbegintag(htmltextwritertag.input);

writer.renderendtag();

writer.renderendtag();

writer.renderendtag();

writer.renderbegintag(htmltextwritertag.tr);

writer.renderbegintag(htmltextwritertag.td);

writer.addattribute(htmltextwriterattribute.type,"submit");

writer.addattribute(htmltextwriterattribute.id,this.inbuttonid);

writer.addattribute(htmltextwriterattribute.name,this.inbuttonname);

writer.addattribute(htmltextwriterattribute.value,this.inbuttontext);

writer.renderbegintag(htmltextwritertag.input);

writer.renderendtag();

writer.renderbegintag(htmltextwritertag.td);

writer.addattribute(htmltextwriterattribute.type,"submit");

writer.addattribute(htmltextwriterattribute.id,this.outbuttonid);

writer.addattribute(htmltextwriterattribute.name,this.outbuttonname);

writer.addattribute(htmltextwriterattribute.value,this.outbuttontext);

writer.renderbegintag(htmltextwritertag.input);

writer.renderendtag();

writer.renderendtag();

writer.renderendtag();

}#endregion}}

將以上**編譯成元件後拖拉至設計頁面login.aspx

login.aspx檔案 :

<%@ page language="c#" codebehind="login.aspx.cs" autoeventwireup="false" inherits="play.webform1" %>

<%@ register tagprefix="loginon" namespace="webframe" assembly="webframe"%>

後**檔案login.aspx.cs:

this.aaa.loginin += new system.eventhandler(this.aaa_loginin);

this.aaa.loginout += new system.eventhandler(this.aaa_loginout);

private void aaa_loginin(object sender ,system.eventargs e)

private void aaa_loginout(object sender, system.eventargs e)

使用者模組之使用者登入

使用者登入流程 接受資料 接受瀏覽器傳遞過來的資料 校驗資料 資料完整性校驗 all 業務處理 登入校驗 登入認證 authenticate username username,password password 認證一組給定的使用者名稱和密碼 判斷使用者已啟用 記錄使用者的登入狀態,login r...

伺服器控制項

本章學習了asp.nte頁面的乙個核心構造塊 伺服器控制項。伺服器控制項是一種用於頁面開發的物件導向方法,它把頁面元素封裝到可修改和可擴充套件的元件中。伺服器控制項型別包括 web伺服器控制項和html伺服器控制項 web伺服器控制項的2個特點 必須有id和runat server html元素加上...

Linux FTP伺服器本地使用者登入

在這篇文章中,我將通過vsftp對ftp伺服器進行配置。並且以本地使用者形式,實現vm虛擬機器下的linux系統和實際的windows系統進行互動。我的liunx系統是centos6系統 ftp服務的具體工作過程如下 當ftp客戶端發出請求時,系統將動態分配乙個埠 如1032 若ftp伺服器在埠21...