ADO.net


1. Textbox :-
<asp:textbox id=t1 runat=server/>
<asp:textbox id=t2 textmode=password runat=server/>
<asp:textbox id=t3 textmode=multiline rows=10 cols=20 runat=server/>

2. Button :-
<asp:button id=b1 text=OK runat=server/>
<asp:linkbutton id=lb1 text=www.yahoo.com runat=server/>
<asp:imagebutton id=im1 imageurl=~/image/Sunset.jpg
         Width="1in" Height="1in" runat=server/>
3. Label:-
<asp:label id=l1 text="name:- " runat=server/>

Light weight
1. Instead of lable just write text in td

4. Radiobutton:-
 <asp:radiobutton id=rb1 text=male runat=server GroupName="gr1"/>
          <asp:radiobutton id=rb2 text=Female runat=server GroupName="gr1"/>
6. RadiobuttonList:-
 <asp:radiobuttonlist id=dsgfd runat=server>
 <asp:ListItem>female</asp:ListItem>
          <asp:ListItem>male</asp:ListItem>
 </asp:radiobuttonlist>

5. CheckBox :-
 <asp:checkbox id=cb1 text=male runat=server />
          <asp:checkbox  id=cb2 text=Female runat=server/>

7. Checkboxlist:-
 <asp:checkboxlist id=dsgfd runat=server>
 <asp:ListItem>female</asp:ListItem>
          <asp:ListItem>male</asp:ListItem>
 </asp:checkboxlist>

8. dropdownlist :-

 <asp:dropdownlist id=dsgfd runat=server>
 <asp:ListItem>female</asp:ListItem>
          <asp:ListItem>male</asp:ListItem>
 </asp:dropdownlist>

9. Listbox :-
<asp:ListBox ID="ListBox1" runat="server">
        <asp:ListItem>aaaa</asp:ListItem>
        </asp:ListBox>

Events
=========
1. Button :- Event :-
onClick()
onCommand():- We can pass parameter.. from .aspx to .cs


.Aspx:-
========
<asp:button id=b1 text=ok runat=server onClick=a/>

<asp:button id=b1 text=ok runat=server onCommand=b commandname="a" commandargumnet="santosh"/>


.Cs:-
========
public void a(Object e, EventArgs t)
{
Response.Write("hahahaha");
}

public void b(Object e,CommandEventArgs t)
{
Response.Write(t.ArgumentName);
}

===To use MessageBox in Asp.net
1. Add Reference of System.Windows.Forms

System.Windows.Forms.M....



2. RadioButton/CheckBox:-
OnCheckdChanged()

**Autopostback:-
Posting of page on server
or,
refresh the page
or,
Submitting the page on server

by default normally controll : autopoastback=false
other th button(By default true)

HTML : Submit:


eg:-
 <asp:RadioButton ID="R1" Text="Red" runat="server" GroupName="gr1"
            OnCheckedChanged="a" AutoPostBack="True"/>      
        <asp:RadioButton ID="R2" Text="Green" runat="server" GroupName="gr1"
            OnCheckedChanged="b" AutoPostBack="True" />      
      
        <asp:CheckBox ID="C1" runat="server" AutoPostBack="True"
            oncheckedchanged="CheckBox1_CheckedChanged" Text="MCA" />

.cs:-
====
    protected void a(object sender, EventArgs e)
    {
        Response.Write("Your Color is-->" + RadioButton1.Text);
    }
    protected void b(object sender, EventArgs e)
    {
        Response.Write("Your Color is-->" + RadioButton2.Text);
    }
    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        if (CheckBox1.Checked == true)
        {
            Response.Write("Your qualifiaction is-->" + CheckBox1.Text);
        }
        else
        {
            Response.Write("Your qualifiaction is not-->" + CheckBox1.Text);
        }
    }


 How to pass the value from ..cs page to .aspx page:-
==========================================================
.aspx page:-
=============
<body bgcolor="<%=cl%>">

.cs page:-
===========
    public string cl="";
    protected void Page_Load(object sender, EventArgs e)
    {
        cl = "Orange";
    }
    protected void a(object sender, EventArgs e)
    {
       cl=RadioButton1.Text;
    }
    protected void b(object sender, EventArgs e)
    {
        cl=RadioButton2.Text;
    }





Comments

Popular posts from this blog

C# Connectivity with MySql Server..