一、简单控件

1、label:边框(边框的颜色、样式、粗细)  是专门显示文字的,   被编译后是    <span id="Label1">Label</span>

2、Literal:  Text属性,作用显示文字  编译后不会形成任何元素,一般被用来输出Js代码,比较灵活

<asp:Literal ID="Literal2" runat="server" Text="mm"></asp:Literal>

3、Textbox:文字输入框, 编译后是:<input name="TextBox3" type="password" id="TextBox3" />

属性:  wrap:自动换行,

Text Mode:可以是文本框、密码框(password)

SingleLine 被编译为 type="text"

--MultiLine  被编译为  type="text"

--Password 被编译为  textarea

Enabled:可用 或 不可用,编译后是:<input name="TextBox3" type="password" id="TextBox3" disabled="disabled" class="aspNetDisabled" />

Readonly:只读,

Maxlength:限制长度,一般用于用户名、密码的长度。

--

4、Button:按钮,编译后是   <input type="submit" name="Button2" value="Button" id="Button2" />提交按钮

OnclientClick:在服务端上的点击事件,编译为click        confirm   验证判断

5、ImageButton:属性:imageurl:图片地址,——提交

6、LinkButton:超链接,

7、Hyperlink:超链接样式按钮

二、简单登录

.aspx页面:

   <title></title>
<style type="text/css"> //设置button 按钮样式
#Button1 {
width:100px;
height:30px;
background-color:yellow;
color:green;
font-size:18px;
font-family:黑体;
font-weight:bold;
} </style>
</head>
<body> <form id="form1" runat="server" text="xm">
用户名:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br/>
密码:<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /> //登录的界面
<asp:Button ID="Button1" runat="server" Text="登录" />
<asp:Literal ID="Literal1" runat="server"></asp:Literal> </form>
</body>
</html>

.cs页面

public partial class zhuce : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button1.Click += Button1_Click;//登录按钮 按两次Tab
} void Button1_Click(object sender, EventArgs e)
{
//先把用户名和密码取出 连接数据库三个类
string Uname = TextBox1.Text;
string Pwd = TextBox2.Text;
bool isok = new UsersDA().Select(Uname,Pwd);
if (isok)
{
Literal1.Text = "登录成功!";
}
else
{
Literal1.Text = "用户名密码错误";
}
}

链接数据库:

App_Code  把所有类放入此文件夹中

没有命名空间

1、实体类

2、数据访问类:

public class UsersDA
{
SqlConnection conn = null;
SqlCommand cmd = null;
public UsersDA()
{
conn = new SqlConnection("server=.;database=Data0617;user=sa;pwd=100867");
cmd = conn.CreateCommand();
}
/// <summary>
/// 用户验证
/// </summary>
/// <param name="Uname">验证的用户名</param>
/// <param name="Pwd">验证的密码</param>
/// <returns></returns>
public bool Select(string Uname,string Pwd) {
bool has = false;
cmd.CommandText = "select * from Users where UserName=@username and PassWord=@password";
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@username",Uname);
cmd.Parameters.AddWithValue("@password",Pwd);
conn.Open();
SqlDataReader dr= cmd.ExecuteReader();
if (dr.HasRows)
{
has = true;
} conn.Close();
return has;
}

WebForm--j简单控件、简单的登录(怎么链接数据库)的更多相关文章

  1. UWP入门(一) -- 先写几个简单控件简单熟悉下(别看这个)

    原文:UWP入门(一) -- 先写几个简单控件简单熟悉下(别看这个) 1. MainPage.xmal <Grid Background="{ThemeResource Applica ...

  2. Webform(简单控件、复合控件)

    一.简单控件: 1.label控件 <asp:Label ID="Label1" runat="server" Text="账 号:" ...

  3. WebForm 【简单控件】【表单元素】

    一.HTML 表单元素复习 (1)文本类 文本框:<input type="text" name="" id="" value=&qu ...

  4. WebForm简单控件,复合控件

    简单控件: 1.Label 会被编译成span标签 属性: Text:文本内容 CssClass:CSS样式 Enlabled:是否可用 Visible:是否可见 __________________ ...

  5. webform简单控件

    表单元素: 文本类: text password textarea hidden text,password,textarea实现控件:textbox   textmode属性选择password或m ...

  6. WebForm 简单控件、复合控件

    简单控件: Label:被编译成span 样式表里设置lable的高度:  display:inline-block; Text  --文本 ForeColor  --字体颜色 Visible  -- ...

  7. 【2017-05-18】WebForm的Repeater控件和一些简单控件

    一.Repeater控件 1. <%@ %> - 这里面写一些声明和引用的 <%  %> - 编写C#代码的 <%= %> - 往界面上输出一个变量的值 <% ...

  8. 【2017-05-18】WebForm的Repeater控件及简单控件

    <%@ %> - 这里面写一些声明和引用的 <%  %> - 编写C#代码的 <%= %> - 往界面上输出一个变量的值 <%# Eval("属性名 ...

  9. 2013 duilib入门简明教程 -- 简单控件介绍 (12)

        前面的教程应该让大家对duilib的整体有所映像了,下面就来介绍下duilib具体控件的使用.     由于官方没有提供默认的控件样式,所以我就尽量使用win7或者XP自带的按钮样式了,虽然界 ...

随机推荐

  1. Visual Studio Code 插件推荐

    Path Intellisense - 路径补全 HTML Snippets - HTML 标记增强 Markdown+Math - Markdown 增强(数学表达式) vscode-icons - ...

  2. java StringUtils

    /** * */ package com.sign.utils; import java.util.regex.Pattern; /** * @author Administrator * creat ...

  3. php多进程防止出现僵尸进程

    对于用PHP进行多进程并发编程,不可避免要遇到僵尸进程的问题. 僵尸进程是指的父进程已经退出,而该进程dead之后没有进程接受,就成为僵尸进程(zombie)进程.任何进程在退出前(使用exit退出) ...

  4. eas之视图冻结与解冻

    // 冻结视图 table.getViewManager().freeze(verticalIndex, horizonIndex); //冻结视图:该方法在table还没显示的时候使用,也就是该方法 ...

  5. android apk的签名和权限问题

    一. android apk的签名问题(http://blog.csdn.net/lyq8479/article/details/6401093) 1.为什么要给Android应用程序签名?      ...

  6. Node.js+Protractor+vscode搭建测试环境(1)

    1.protractor简介 官网地址:http://www.protractortest.org/ Protractor是一个end-to-end的测试框架,从网络上得到的答案是Protractor ...

  7. Ubuntu Server下docker实战 02: docker进阶配置

    在上一篇文章里<Ubuntu Server下docker实战 01: 安装docker>,我们已经把docker安装起来了,并运行了一个hello-world 这一篇,我们继续讲进阶配置. ...

  8. 37.query string、_all metadata

    主要知识点 1.query string基础语法 2._all metadata的理解     一.query string基础语法 1.GET /test_index/test_type/_sear ...

  9. 1.IDEA的安装

    .1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16.

  10. 我的网站恢复访问了,http://FansUnion.cn

    博客网站 http://FansUnion.cn 恢复访问了. 周末,发表几篇原创文章.