ASP.NET C# TAGS.
Text box
<Asp: textbox Run AT = “Server” id= “txt” />
Button
<Asp: button Run At = “Server” id = “btn” />
Label
<Asp: label Run At = “Server” id = “label” />
Start directive tag of the asp.net:
<@ language = “c#” code file = “index.aspx.cs” >
Master page:
<%@ master language = “c#” code file = “def.master.cs” inherits = “_def.” %>
Form:
<Asp: form Run At = “server” id = “form”>
Contentplaceholder:
<Asp: content placeholder Id = “cnt1” Run At = “server”>
First Tag of default.aspx
<%@ page language = “c#” code file = “def.aspx.cs” inherits = “_def.” master file = “def_master”
%>
CONTROL STRUCTURE IN C#:
If, for, while, do while, switch etc.
IF:
If(a>b)
Out >> “a is greater than b”;
Else
Out >> “b is greater than a”;
For:
For (starting (in it); condition; increment/decrement)
Int i=1;
For (int i=1, i<=10, i++)
Response. Write (i);
For Each Loop:
For (each variable name)
Int i[]={1,2,3,4}
For (each int j in i)// j which array’s value will copy and I where it will copy
Response. Write (j);
Control Lists:
1. Bullet list
2. List box
3. Check box list
4. Radio button list
5. Drop down list
These are inherits from List Control
Then
Checkbox list:
Name and id will same in check box list
Radio Button:
Multiple option single selection
Drop Down list:
Single and multiple option can be selected.
Adding items in Check Box List At Design Time:// in file.aspx:
<ASP: Checkbox list id = “chkl1” run at = “server”/>
<ASP: List item> MSC </ASP: List item>
<ASP: List item> BSC </ASP: List item>
</ASP: Checkbox list>
In this condition value MSc and BSc will send to server. If we want that some other
Value should have to be send to the server instead of MSc then by this way we will give
Value to the items
< ASP: List item value = 1> MSC </ASP: List item >
< ASP: List item value = 2> MSC </ASP: List item >
Now 1 and 2 value will send to the server instead of MSc and BSc.
IF we want to add any check box at run time that will be added
in file.aspx.cs file
By this method.
Protected void Add list () {
List Item li = new list item (“MSIT”, “3”);
List Item li = new list item (“BSIT”, “4”);
Chkl1.item.add (li)
Chkl1.item.add (li2)
HOW TO RETRIVE THESE ITEMS:
Protected void list show () {
Int [] i= {4, 5, 6, 7}
For (each int j in i) {
Respose.write(“j”);
}
By this method all item will retrived.
If we wand to retrieve every item saperately then use this
method:
Protected void list_show(){
For each(listitem j in list.listitem)}
{
If(j.selected == true){
Response.write(“j.selectedIndex”)
OR
Response.write(“j.Value”)
OR
Response.write(“j.text”)
OR
Response.write(“j.selected”)// it will return true or false.