WebForm control and webform Control

Source: Internet
Author: User

WebForm control and webform Control

Simple controls

Text:

Label -- display text

Border

To set: 1. border color 2. Border Style 3. Border Width

Attribute: BackColor

BorderColor/BorderStyle/BorderWidth -- set the border

Literal

It is generally used to output JS Code.

TextBox: text input box

Attribute: TextMode -- MultLine multi-line (text field) is compiled as Textarea

Password single-line Password box

Singleline single-line text box

Wrap -- automatic line feed

Enable -- available or not

Readonly -- read-only

The maximum length of maxlength, used to limit the number of characters entered by the user.

 

Button class:

Button, compiled as submit

<input type="submit" name="Button1" value="Button" id="Button1" />

OnclientClick: click Event on the server, compiled as click

Confirm -- verify and judge

 

ImageButton -- image button

The ImageUrl attribute specifies the image address.

LinkButton -- hyperlink

Hyperlink -- Hyperlink style button

------------------------------------------------------

Login:

Webform database connection method-No namespace

Class to be added to App_Code

 

Delegate:

Loading events:

Button1.Click + = button#click;

Void button#click (object sender, EventArgs e) {string Uname = TextBox1.Text; string Pwd = TextBox2.Text; bool isok = new UserDA (). select (Uname, Pwd); if (isok) Literal1.Text = "<script> alert ('login successfully') </script> "; else Literal1.Text = "<script> alert ('logon failed') </script> ";}

Data Category:

Public class UserDA {SqlConnection conn = null; SqlCommand cmd = null; public UserDA () {conn = new SqlConnection ("server = .; database = Data0617; user = sa; pwd = 123 "); cmd = conn. createCommand ();} /// <summary> /// user verification /// </summary> /// <param name = "Username"> verify the user name </param> /// <param name = "Pwd"> verify password </param> // <returns> </returns> public bool Select (string Username, string Pwd) {bool has = false; cmd. commandText = "select * from Users where Username = @ user and Password = @ pwd"; cmd. parameters. clear (); cmd. parameters. addWithValue ("@ user", Username); cmd. parameters. addWithValue ("@ pwd", Pwd); conn. open (); SqlDataReader dr = cmd. executeReader (); if (dr. hasRows) {has = true;} conn. close (); return has ;}

 

------------------------------------------

Composite Control:

Name: used by the server.

Id: used by the client.

DropDownList-- Compile to Select option
1. Put data in

<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>

<Asp: Button ID = "Button1" runat = "server" Text = "Button 1"/>
<Asp: Label ID = "Label1" runat = "server" Text = "Label"> </asp: Label>

Using System; using System. collections. generic; using System. linq; using System. web; using System. web. UI; using System. web. UI. webControls; public partial class _ Default: System. web. UI. page {protected void Page_Load (object sender, EventArgs e) {// first binding method: // DropDownList1.DataSource = new NationData (). select (); // the data source points to // DropDownList1.DataTextField = "NationName"; // display field binding // DropDownList1.DataValueField =" NationCode "; // hide the field binding // DropDownList1.DataBind (); // The second binding method is: if (! IsPostBack) {List <Nation> Nlist = new NationData (). select (); foreach (Nation n in Nlist) {ListItem li = new ListItem (n. nationName, n. nationCode); if (li. value = "N003") {li. selected = true;} RadioButtonList1.Items. add (li) ;}} Button1.Click + = button#click; // button 1 Click Event} void button#click (object sender, EventArgs e) {string end = ""; foreach (ListItem li in RadioButtonList1.Items) {if (li. selected) {end + = li. text + "-" + li. value + "," ;}} Label1.Text = end ;}}

 





ListBox

Multiple options:-SelectionMode

RadioButtonList

CheckBoxList

RepeatDirection = "Horizontal" Horizontal arrangement, Vertical arrangement

RepeatColumns = "3": three rows in a row

RepeatLayout = "UnorderedList unordered

RepeatLayout = "OrderedList ordered

RepeatLayout = "Flow" streaming layout. The compiled layout is span.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.