第二章 简单登录页面
3、心得
从第二章开始算是正式学习了,有点不解的地方就是教程是先用另一个dll,
ExtAspNet。直接用FineUI不好么?
1、下载好以下东西先:
ExtAspNet:博主要求先用的控件。
Newtonsoft.Json.dll:需要添加的引用,不然会报错。
FineUI的资源文件,再添加引用FredCK.FCKeditorV2.dll,不然也会报错。
2、先进行web.config全局设置。
<configuration>
<configSections>
<section name="ExtAspNet" type="ExtAspNet.ConfigSection, ExtAspNet" requirePermission="false"/>
</configSections>
<ExtAspNet EnableBigFont="true" DebugMode="true" IconBasePath="~/Fineui/icon"/>
<!--连接字符串-->
<connectionStrings>
<add name="localOraclStr" connectionString="Data Source=192.168.2.244/orcl;User ID=platform;pwd=pf123;Unicode=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<controls>
<add assembly="ExtAspNet" namespace="ExtAspNet" tagPrefix="ext"/>
</controls>
</pages>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<modules>
<add name="ExtAspNetScriptModule" type="ExtAspNet.ScriptModule, ExtAspNet"/>
<!--<add type="wqcms.URLRewriter.ModzuleRewriter, wqcms_URLRewriter" name="ModuleRewriter" />-->
</modules>
<handlers>
<add name="ExtAspNetResourceHandler" verb="GET" path="res.axd" type="ExtAspNet.ResourceHandler, ExtAspNet"/>
</handlers>
</system.webServer>
</configuration>
2、新控件ext:Window ,可以像一个模式窗口一样随便拉动,很炫。特殊属性WindowPosition="GoldenSection"
3、新控件ext:SimpleForm,简单表单,我想应该是。。。
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<link href="Fineui/css/main.css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<ext:PageManager ID="PageManager1" runat="server" />
<div>
用户名:admin
<br />
密码:admin
<br />
<ext:Window ID="Window1" runat="server" Title="登录表单" IsModal="false" EnableClose="false"
WindowPosition="GoldenSection" Width="350px">
<Items>
<ext:SimpleForm ID="SimpleForm1" runat="server" ShowBorder="false" BodyPadding="10px"
LabelWidth="60px" EnableBackgroundColor="true" ShowHeader="false">
<Items>
<ext:TextBox ID="tbxUserName" Label="用户名" Required="true" runat="server">
</ext:TextBox>
<ext:TextBox ID="tbxPassword" Label="密码" TextMode="Password" Required="true" runat="server">
</ext:TextBox>
<ext:Button ID="btnLogin" Text="登录" Type="Submit" ValidateForms="SimpleForm1" ValidateTarget="Top"
runat="server" OnClick="btnLogin_Click">
</ext:Button>
</Items>
</ext:SimpleForm>
</Items>
</ext:Window>
</div>
</form>
</body>
</html>
protected void btnLogin_Click(object sender, EventArgs e)
{
if (tbxUserName.Text == "admin" && tbxPassword.Text == "admin")
{
Alert.ShowInTop("成功登录!");
}
else
{
Alert.ShowInTop("用户名或密码错误!", MessageBoxIcon.Error);
}
}
3、心得
1)Alert的提示
2)window窗体控件,和他的属性
WindowPosition="GoldenSection"
3)控件
ext:SimpleForm,简单表单,和button配合用。
关键在:Type="Submit" ValidateForms="SimpleForm1"