asp.Netページ評価テストインスタンスコード(フロントバックグラウンド)
8756 ワード
WebForm_1.aspxの内容は以下の通りです.
<br/>
<br/>
<br/><form id="form1" runat="server">
<br/><div>
<br/><table id="TableLogin" runat="server">
<br/><tablerow>
<br/><tablecell><label> :</label></tablecell>
<br/><tablecell><textbox id="UserName" runat="server" width="150px"/></tablecell>
<br/></tablerow>
<br/><tablerow>
<br/><tablecell><label> :</label></tablecell>
<br/><tablecell><textbox id="PassWord" runat="server" width="150px"/></tablecell>
<br/></tablerow>
<br/><tablerow>
<br/><tablecell><label> :</label></tablecell>
<br/><tablecell><textbox id="ConfimPWD" runat="server" width="150px"/></tablecell>
<br/></tablerow>
<br/><tablerow>
<br/><tablecell><button id="Confirm" runat="server" text=" " width="50px" onclick="Confirm_Click"/></tablecell>
<br/></tablerow>
<br/></table>
<br/></div>
<br/></form>
<br/>
<br/>
<br/>
</code></pre>
<br/>WebForm_2.aspx :
<br/>
<pre><code>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/><title/>
<br/>
<br/>
<br/><form id="form1" runat="server">
<br/><div>
<br/></div>
<br/></form>
<br/>
<br/>
<br/>
</code></pre>
<br/>WebForm_1.aspx.cs :
<br/>
<pre><code>
<br/>using System;
<br/>using System.Collections.Generic;
<br/>using System.Linq;
<br/>using System.Web;
<br/>using System.Web.UI;
<br/>using System.Web.UI.WebControls;
<br/>namespace
<br/>{
<br/>public partial class WebForm_1 : System.Web.UI.Page
<br/>{
<br/>protected void Page_Load(object sender, EventArgs e)
<br/>{
<br/>}
<br/>public string un//
<br/>{
<br/>get
<br/>{
<br/>return UserName.Text;
<br/>}
<br/>}
<br/>public string pwd//
<br/>{
<br/>get
<br/>{
<br/>return PassWord.Text;
<br/>}
<br/>}
<br/>public string conpwd//
<br/>{
<br/>get
<br/>{
<br/>return ConfimPWD.Text;
<br/>}
<br/>}
<br/>/// <summary>
<br/>/// WebForm_2.aspx
<br/>/// </summary>
<br/>/// <param name="sender"/>
<br/>/// <param name="e"/>
<br/>protected void Confirm_Click(object sender, EventArgs e)
<br/>{
<br/>//1:QueryString
<br/>//string url = "WebForm_2.aspx?un=" + UserName.Text + "&userpassword=" + PassWord.Text + "&conPwd=" + ConfimPWD.Text;
<br/>//Response.Redirect(url);
<br/>//2:Session
<br/>//Session["un"] = UserName.Text;
<br/>//Session["pwd"] = PassWord.Text;
<br/>//Session["conpwd"] = ConfimPWD.Text;
<br/>//Server.Transfer("WebForm_2.aspx");
<br/>//3: cookie
<br/>//HttpCookie cookie_name = new HttpCookie("un");
<br/>//cookie_name.Value = UserName.Text;
<br/>//HttpCookie cookie_pwd = new HttpCookie("pwd");
<br/>//cookie_pwd.Value = PassWord.Text;
<br/>//HttpCookie cookie_conpwd = new HttpCookie("conpwd");
<br/>//cookie_conpwd.Value = ConfimPWD.Text;
<br/>//Response.AppendCookie(cookie_name);
<br/>//Response.AppendCookie(cookie_pwd);
<br/>//Response.AppendCookie(cookie_conpwd);
<br/>//Server.Transfer("WebForm_2.aspx");
<br/>//4: application , session ,
<br/>//Application["un"] = UserName.Text;
<br/>//Application["pwd"] = PassWord.Text;
<br/>//Application["conpwd"] = ConfimPWD.Text;
<br/>//Response.Redirect("WebForm_2.aspx");
<br/>Server.Transfer("WebForm_2.aspx");
<br/>}
<br/>}
<br/>}
<br/>
</code></pre>
<br/>WebForm_2.aspx.cs :
<br/>
<pre><code>
<br/>using System;
<br/>using System.Collections.Generic;
<br/>using System.Linq;
<br/>using System.Web;
<br/>using System.Web.UI;
<br/>using System.Web.UI.WebControls;
<br/>namespace
<br/>{
<br/>public partial class WebForm_2 : System.Web.UI.Page
<br/>{
<br/>protected void Page_Load(object sender, EventArgs e)
<br/>{
<br/>//QueryTransfer();
<br/>//SessionTransfer();
<br/>//CookieTransfer();
<br/>//ApplicationTransfer();
<br/>Transfer();
<br/>}
<br/>public void QueryTransfer()// QueryString , WebForm_1
<br/>{
<br/>string strUserName = Request.QueryString["un"].ToString();
<br/>string strPassword = Request.QueryString["userpassword"].ToString();
<br/>string strPWD = Request.QueryString["conPwd"].ToString();
<br/>Response.Write(" " + strUserName + "<br/>" + " " + strPassword + "<br/>" + " " + strPWD);
<br/>}
<br/>public void SessionTransfer()// session , WebForm_1
<br/>{
<br/>string strUserName = Session["un"].ToString();
<br/>string strPassword = Session["pwd"].ToString();
<br/>string strPWD = Session["conpwd"].ToString();
<br/>Response.Write(" " + strUserName + "<br/>" + " " + strPassword + "<br/>" + " " + strPWD);
<br/>Session.Remove("un");
<br/>Session.Remove("pwd");
<br/>Session.Remove("conpwd");
<br/>}
<br/>public void CookieTransfer()// cookie , WebForm_1
<br/>{
<br/>string strUserName = Request.Cookies["un"].Value.ToString();
<br/>string strPassword = Request.Cookies["pwd"].Value.ToString();
<br/>string strPWD = Request.Cookies["conpwd"].Value.ToString();
<br/>Response.Write(" " + strUserName + "<br/>" + " " + strPassword + "<br/>" + " " + strPWD);
<br/>}
<br/>public void ApplicationTransfer()// Application , WebForm_1
<br/>{
<br/>Application.Lock();
<br/>string strUserName = Application["un"].ToString();
<br/>string strPassword = Application["pwd"].ToString();
<br/>string strPWD = Application["conpwd"].ToString();
<br/>Application.UnLock();
<br/>if (strPassword != strPWD)
<br/>{
<br/>Response.Write(" , !<br/>");
<br/>Server.Transfer("WebForm_1.aspx");
<br/>}
<br/>Response.Write(" " + strUserName + "<br/>" + " " + strPassword + "<br/>" + " " + strPWD);
<br/>}
<br/>public void Transfer()//Transfer , WebForm_1.aspx
<br/>{
<br/>WebForm_1 wf1;
<br/>wf1 = (WebForm_1)Context.Handler;
<br/>string strUserName = wf1.un;
<br/>string strPassword = wf1.pwd;
<br/>string strPWD = wf1.conpwd;
<br/>Response.Write(" " + strUserName + "<br/>" + " " + strPassword + "<br/>" + " " + strPWD);
<br/>}
<br/>}
<br/>}
<br/>
</code></pre>
<br/> , !
<div class="clearfix">
<span id="art_bot" class="jbTestPos"/>
</div>
</div>
</div>
</div>