asp.net頁(yè)面?zhèn)髦禍y(cè)試實(shí)例代碼_.Net教程
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
推薦:DataGridView - DataGridViewCheckBoxCell的使用介紹Datagridview是.net中最復(fù)雜的控件,由于人們對(duì)表格的格式要求多種多樣,所以編寫(xiě)一個(gè)通用的Datagridview(類(lèi)似JSF中的datatable)非常困難的。 Datagridview中,用戶(hù)可以對(duì)行、列、單元格進(jìn)行編程。如行中可以插入下拉列表、復(fù)選框、編輯框、單選框等多種控件。每種控
WebForm_1.aspx內(nèi)容如下:
復(fù)制代碼 代碼如下:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm_1.aspx.cs" Inherits="頁(yè)面?zhèn)髦?WebForm_1" %>
<!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">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Table ID="TableLogin" runat='server'>
<asp:TableRow>
<asp:TableCell><label>用戶(hù)名:</label></asp:TableCell>
<asp:TableCell><asp:TextBox ID="UserName" runat="server" Width="150px"></asp:TextBox></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell><label>密碼:</label></asp:TableCell>
<asp:TableCell><asp:TextBox ID="PassWord" runat="server" Width="150px"></asp:TextBox></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell><label>驗(yàn)證密碼:</label></asp:TableCell>
<asp:TableCell><asp:TextBox ID="ConfimPWD" runat="server" Width="150px"></asp:TextBox></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell><asp:Button ID="Confirm" runat="server" Text="確認(rèn)" Width="50px" OnClick="Confirm_Click" /></asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</form>
</body>
</html>
WebForm_2.aspx頁(yè)面如下:
<%@ Reference Page="~/WebForm_1.aspx" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm_2.aspx.cs" Inherits="頁(yè)面?zhèn)髦?WebForm_2" %>
<!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">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
WebForm_1.aspx.cs文件如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace 頁(yè)面?zhèn)髦?
{
public partial class WebForm_1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public string un//得到用戶(hù)名
{
get
{
return UserName.Text;
}
}
public string pwd//得到密碼
{
get
{
return PassWord.Text;
}
}
public string conpwd//得到確認(rèn)密碼
{
get
{
return ConfimPWD.Text;
}
}
/// <summary>
/// 向WebForm_2.aspx頁(yè)面?zhèn)髦?
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Confirm_Click(object sender, EventArgs e)
{
//1:QueryString頁(yè)面?zhèn)髦?
//string url = "WebForm_2.aspx?un=" + UserName.Text + "&userpassword=" + PassWord.Text + "&conPwd=" + ConfimPWD.Text;
//Response.Redirect(url);
//2:Session傳值
//Session["un"] = UserName.Text;
//Session["pwd"] = PassWord.Text;
//Session["conpwd"] = ConfimPWD.Text;
//Server.Transfer("WebForm_2.aspx");
//3:使用cookie對(duì)象傳值
//HttpCookie cookie_name = new HttpCookie("un");
//cookie_name.Value = UserName.Text;
//HttpCookie cookie_pwd = new HttpCookie("pwd");
//cookie_pwd.Value = PassWord.Text;
//HttpCookie cookie_conpwd = new HttpCookie("conpwd");
//cookie_conpwd.Value = ConfimPWD.Text;
//Response.AppendCookie(cookie_name);
//Response.AppendCookie(cookie_pwd);
//Response.AppendCookie(cookie_conpwd);
//Server.Transfer("WebForm_2.aspx");
//4:使用application對(duì)象傳值,類(lèi)似session傳值,作用范圍全局所有用戶(hù)
//Application["un"] = UserName.Text;
//Application["pwd"] = PassWord.Text;
//Application["conpwd"] = ConfimPWD.Text;
//Response.Redirect("WebForm_2.aspx");
Server.Transfer("WebForm_2.aspx");
}
}
}
分享:asp.net中javascript的引用(直接引入和間接引入)Asp.net 中引入Javascript 的方法有很多。在做牛腩的時(shí)候主要講了兩種。 個(gè)人認(rèn)為可以分為直接引入,和間接引入。 一、直接引入 。在前臺(tái)頁(yè)面調(diào)用自定義的javascript 函數(shù): 1、打開(kāi)前臺(tái)頁(yè)面在 head 元素之間加入 script 元素,將 type 元素設(shè)置為 text/javascript 。然
相關(guān).Net教程:
- asp.net如何得到GRIDVIEW中某行某列值的方法
- .net SMTP發(fā)送Email實(shí)例(可帶附件)
- js實(shí)現(xiàn)廣告漂浮效果的小例子
- asp.net Repeater 數(shù)據(jù)綁定的具體實(shí)現(xiàn)
- Asp.Net 無(wú)刷新文件上傳并顯示進(jìn)度條的實(shí)現(xiàn)方法及思路
- Asp.net獲取客戶(hù)端IP常見(jiàn)代碼存在的偽造IP問(wèn)題探討
- VS2010 水晶報(bào)表的使用方法
- ASP.NET中操作SQL數(shù)據(jù)庫(kù)(連接字符串的配置及獲取)
- DataGridView - DataGridViewCheckBoxCell的使用介紹
- asp.net中javascript的引用(直接引入和間接引入)
- 三層+存儲(chǔ)過(guò)程實(shí)現(xiàn)分頁(yè)示例代碼
- 模板無(wú)憂(yōu):在.NET開(kāi)發(fā)中靈活使用TreeView控件
.Net教程Rss訂閱編程教程搜索
.Net教程推薦
- Ajax簡(jiǎn)單客戶(hù)登陸驗(yàn)證
- 關(guān)于ADO.NET數(shù)據(jù)庫(kù)連接的相關(guān)知識(shí)的總結(jié)
- .net C#生成縮略圖實(shí)現(xiàn)思路分解
- 淺析CMS內(nèi)容管理系統(tǒng)的兩種方案
- 關(guān)于利用C#遠(yuǎn)程存取Access數(shù)據(jù)庫(kù)
- ASP.NET中使用Global.asax文件
- 解析asp.net編程中6條實(shí)用語(yǔ)句
- 解說(shuō)ASP.NET中的session存儲(chǔ)模式運(yùn)用
- ASP.NET立即上手教程(11)
- 揭秘運(yùn)行 ASP 時(shí)腳本超時(shí)問(wèn)題最終解決辦法
- 相關(guān)鏈接:
- 教程說(shuō)明:
.Net教程-asp.net頁(yè)面?zhèn)髦禍y(cè)試實(shí)例代碼
。