Tuesday, May 31, 2011

GridView SelectedIndexChanging

Default.aspx

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_4_Tier_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <style type="text/css">
        body
        {
            font-family: Arial, Trebuchet Ms;
            font-size: 10pt;
        }
    </style>
    <title>Insert Records into DataBase</title>
</head>
<body>
    <h3>
        Demo: 4-Tier Architecture</h3>
    <form id="form1" runat="server">
    <div>
        <p>
            <a href="List.aspx">List Records</a></p>
        <asp:Label ID="lblMessage" runat="Server" ForeColor="red" EnableViewState="False"></asp:Label>
        <table style="border: 2px solid #cccccc;">
            <tr style="background-color: #507CD1; color: White;">
                <th colspan="3">
                    Add Records
                </th>
            </tr>
            <tr>
                <td>
                    First Name:
                </td>
                <td>
                    <asp:TextBox ID="txtFirstName" runat="Server"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="req1" runat="Server" Text="*" ControlToValidate="txtFirstName"
                        Display="dynamic"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Last Name:
                </td>
                <td>
                    <asp:TextBox ID="txtLastName" runat="Server"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="req2" runat="Server" Text="*" ControlToValidate="txtLastName"
                        Display="dynamic"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Age:
                </td>
                <td>
                    <asp:TextBox ID="txtAge" runat="Server" Columns="4"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="req3" runat="Server" Text="*" ControlToValidate="txtAge"
                        Display="dynamic"></asp:RequiredFieldValidator>
                    <asp:CompareValidator ID="Comp1" runat="Server" Text="Only integer" ControlToValidate="txtAge"
                        Operator="DataTypeCheck" Type="Integer"></asp:CompareValidator>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;
                </td>
                <td>
                    <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="AddRecords" />
                </td>
            </tr>
        </table>
        <table>
            <tr>
                <td>
                    <asp:GridView ID="GridView1" runat="server" PageSize="10" AutoGenerateColumns="False"
                        OnSelectedIndexChanging="GridView1_SelectedIndexChanging" AllowPaging="True"
                        SkinID="ProfessionalGV" Width="700px" Visible="true">
                        <Columns>
                            <asp:TemplateField HeaderText="#">
                                <ItemTemplate>
                                    <%# Container.DataItemIndex + 1 %>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="FirstName" HeaderText="FirstName" />
                            <asp:BoundField DataField="LastName" HeaderText="LastName" />
                            <asp:BoundField DataField="Age" HeaderText="Age" />
                            <asp:TemplateField HeaderText="PersonID" Visible="False">
                                <ItemTemplate>
                                    <asp:Label ID="lblPersonID" runat="server" Text='<%# Bind("PersonID") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:CommandField SelectText="Edit" ShowSelectButton="True" />
                        </Columns>
                    </asp:GridView>
                    <asp:HiddenField ID="hdnPersonID" runat="server"></asp:HiddenField>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

 

 

 

 

Default.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _4_Tier_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGrid();
        }
    }
    public void BindGrid()
    {
        GridView1.DataSource = GridDataSource();
        GridView1.DataBind();
    }
    private DataTable GridDataSource()
    {
        PersonBAL p = new PersonBAL();
        DataTable dTable = new DataTable();
        try
        {
            dTable = p.Load();
        }
        catch (Exception ee)
        {
            lblMessage.Text = ee.Message.ToString();
        }
        finally
        {
            p = null;
        }
        return dTable;
    }
    /// <summary>
    /// Add records into database
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    #region AddRecords
    protected void AddRecords(object sender, EventArgs e)
    {
        Person objbo = new Person();
        PersonBAL objbal = new PersonBAL();
        try
        {
            if (btnSubmit.Text == "Submit")
            {
                objbo.FirstName = txtFirstName.Text;
                objbo.LastName = txtLastName.Text;
                objbo.Age = Convert.ToInt32(txtAge.Text);
                int intResult = objbal.Insert(objbo);
                if (intResult > 0)
                {
                    lblMessage.Text = "Record Inserted Successfully";
                }
                else
                {
                    lblMessage.Text = "Name Already Exists";
                }
            }
            else if (btnSubmit.Text == "Update")
            {
                objbo.PersonID = Convert.ToInt32(hdnPersonID.Value);
                objbo.FirstName = txtFirstName.Text;
                objbo.LastName = txtLastName.Text;
                objbo.Age = Convert.ToInt32(txtAge.Text);
                int intResult = objbal.Update(objbo);
                if (intResult > 0)
                {
                    lblMessage.Text = "Record Inserted Successfully";
                }
                else
                {
                    lblMessage.Text = "Name Already Exists";
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        GridView1.EditIndex = -1;
        BindGrid();
        btnSubmit.Text = "Submit";
    }
    #endregion

 

 

 

    #region SelectedIndexChanging
    protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        try
        {
            hdnPersonID.Value = "";
            GridViewRow gvrow = GridView1.Rows[e.NewSelectedIndex];
            hdnPersonID.Value = ((Label)gvrow.FindControl("lblPersonID")).Text.ToString();
            txtFirstName.Text = gvrow.Cells[1].Text.ToString();
            txtLastName.Text = gvrow.Cells[2].Text.ToString();
            txtAge.Text = gvrow.Cells[3].Text.ToString();
            //string ddlStateId = ((Label)gvrow.FindControl("lblstateid")).Text.ToString();
            //string ddldistrictId = ((Label)gvrow.FindControl("lblDistrictID")).Text.ToString();
            //string ddlCityId = ((Label)gvrow.FindControl("lblCityID")).Text.ToString();
            //string ddlpmcId = ((Label)gvrow.FindControl("lblPMCID")).Text.ToString();
            
            // txtPassword.Text = gvrow.Cells[3].Text.ToString();lblPMCID
           
            //ddlCityName.SelectedValue = ddlCityId;
            //ddlDistrictName.SelectedValue = ddldistrictId;
            //ddlStateName.SelectedValue = ddlStateId;
            //ddlpharmacytype.SelectedValue = ddlpmcId;
            //ddlDistrictName.Enabled = true;
            //ddlCityName.Enabled = true;
            
            if (gvrow.Cells[1].Text.ToString().Equals("&nbsp;"))
            {
                txtFirstName.Text = "";
            }
            else
            {
                txtFirstName.Text = gvrow.Cells[1].Text.ToString();
            }
            if (gvrow.Cells[2].Text.ToString().Equals("&nbsp;"))
            {
                txtLastName.Text = "";
            }
            else
            {
                txtLastName.Text = gvrow.Cells[2].Text.ToString();
            }
            if (gvrow.Cells[3].Text.ToString().Equals("&nbsp;"))
            {
                txtAge.Text = "";
            }
            else
            {
                txtAge.Text = gvrow.Cells[3].Text.ToString();
            }
            
           
            btnSubmit.Text = "Update";
        
        }
        catch (Exception ex)
        {
            //lblmsg.ForeColor = System.Drawing.Color.Red;
            //lblmsg.Text = ex.Message.ToString();
        }
    }
    #endregion
}

AppCode/BO/Person.cs

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

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for Person
/// </summary>
public class Person
{
	public Person()
	{
        
	}
    int m_PersonID = 0;
    string m_FirstName = string.Empty;
    string m_LastName = string.Empty;
    int m_Age = 0;
    #region Propertiers
    public int PersonID
    {
        get { return m_PersonID; }
        set { m_PersonID = value; }
    }
    
    public string FirstName
    {
        get { return m_FirstName; }
        set { m_FirstName = value; }
    }
    
    public string LastName
    {
        get { return m_LastName; }
        set { m_LastName = value; }
    }
    
    public int Age
    {
        get { return m_Age; }
        set { m_Age = value; }
    }
    #endregion Properties
}

 

 

 

AppCode/DAL/PersonDAL.cs
-----------------------------
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
/// <summary>
/// Summary description for PersonDAL
/// </summary>
public class PersonDAL 
{
    string connStr = ConfigurationManager.ConnectionStrings["TutTestConn"].ToString();
	public PersonDAL()
	{
	}
    /// <summary>
    /// Used to insert records into database
    /// </summary>
    /// <param name="p"></param>
    /// <returns></returns>
    public int Insert(Person person)
    {
        SqlConnection conn = new SqlConnection(connStr);
        conn.Open();
        SqlCommand dCmd = new SqlCommand("InsertData", conn);
        dCmd.CommandType = CommandType.StoredProcedure;
        try
        {
            
            dCmd.Parameters.AddWithValue("@firstName", person.FirstName);
            dCmd.Parameters.AddWithValue("@lastName", person.LastName);
            dCmd.Parameters.AddWithValue("@age", person.Age);
            return dCmd.ExecuteNonQuery();
        }
        catch
        {
            throw;
        }
        finally
        {
            dCmd.Dispose();
            conn.Close();
            conn.Dispose();
        }
    }
    /// <summary>
    /// Update record into database
    /// </summary>
    /// <param name="p"></param>
    /// <returns></returns>
    public int Update(Person person)
    {
        SqlConnection conn = new SqlConnection(connStr);
        conn.Open();
        SqlCommand dCmd = new SqlCommand("UpdateData", conn);
        dCmd.CommandType = CommandType.StoredProcedure;
        try
        {
            dCmd.Parameters.AddWithValue("@firstName", person.FirstName);
            dCmd.Parameters.AddWithValue("@lastName", person.LastName);
            dCmd.Parameters.AddWithValue("@age", person.Age);
            dCmd.Parameters.AddWithValue("@personID", person.PersonID);
            return dCmd.ExecuteNonQuery();
        }
        catch
        {
            throw;
        }
        finally
        {
            dCmd.Dispose();
            conn.Close();
            conn.Dispose();
        }
    }
    /// <summary>
    /// Load all records from database
    /// </summary>
    /// <returns></returns>
    public DataTable Load()
    {
        SqlConnection conn = new SqlConnection(connStr);
        SqlDataAdapter dAd = new SqlDataAdapter("LoadAll", conn);
        dAd.SelectCommand.CommandType = CommandType.StoredProcedure;
        DataSet dSet = new DataSet();
        try
        {
            dAd.Fill(dSet, "PersonTable");
            return dSet.Tables["PersonTable"];
        }
        catch
        {
            throw;
        }
        finally
        {
            dSet.Dispose();
            dAd.Dispose();
            conn.Close();
            conn.Dispose();
        }
    }
    /// <summary>
    /// Delete record from database
    /// </summary>
    /// <param name="person"></param>
    /// <returns></returns>
    public int Delete(Person person)
    {
        SqlConnection conn = new SqlConnection(connStr);
        conn.Open();
        SqlCommand dCmd = new SqlCommand("DeleteData", conn);
        dCmd.CommandType = CommandType.StoredProcedure;
        try
        {
            dCmd.Parameters.AddWithValue("@personID", person.PersonID);
            return dCmd.ExecuteNonQuery();
        }
        catch
        {
            throw;
        }
        finally
        {
            dCmd.Dispose();
            conn.Close();
            conn.Dispose();
        }
    }
}
Stored Procedure
-----------------------
//InsertData
Create procedure InsertData
(
 @firstName varchar(200),
 @lastName varchar(200),
 @age int
)
As
Insert into Person (FirstName,LastName,Age)
 Values(@firstName,@lastName,@age)
//UpdateData
Create PROCEDURE UpdateData
(
	@personID int,
	@firstName varchar(50),
	@lastName varchar(50),
	@age int
)
AS
	/* SET NOCOUNT ON */ 
	UPDATE Person SET 
		Firstname = @firstName, 
		Lastname = @lastName, 
		Age = @age 
		WHERE PersonID = @personID
	RETURN
//DeleteData
ALTER PROCEDURE DeleteData
	(
		@personID int
	)
AS
	/* SET NOCOUNT ON */ 
	Delete Person WHERE PersonID = @personID
	RETURN

 

Table Structure:

table



Output:


output

Monday, May 23, 2011

Javascript FromDate to Date Validation

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript">
    function CompareDate(txtfrom, txtto) {
    var From = txtfrom.value;
    var To = txtto.value;
    var strSplitFrom = From.split('/')
    var myDateFrom = new Date();
    myDateFrom.setFullYear(strSplitFrom[2], strSplitFrom[1] - 1, strSplitFrom[0]); 
    var strSplitTo = To.split('/')
    myDateTo = new Date();
    myDateTo.setFullYear(strSplitTo[2], strSplitTo[1] - 1, strSplitTo[0]); 
    if (myDateFrom > myDateTo) { 
        alert("Start date can not greater than End date.");
        txtfrom.focus(); 
        return false;
    }
    else {
        return true;
    } 
}
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <p><b>DD/MM/YEAR Format</b></P>
        From Date<asp:TextBox ID="txtfrom" runat="server"></asp:TextBox>
        <br/>
        To Date 
        <asp:TextBox ID="txtto" runat="server"></asp:TextBox>
        <br/>
        <asp:Button ID="Button1" runat="server" Text="Click" OnClientClick="return CompareDate(txtfrom,txtto);" />
    </div>
    </form>
</body>
</html>
 
javascript1
 
 
 

Friday, May 20, 2011

Hide and Visible using Javascript

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" type="text/javascript">
    function forRentClicked() {

        if (document.getElementById('<%=CheckBox1.ClientID%>').checked == true) {

            RadioButtonList1.style.display = 'block';

        }
        else {
            RadioButtonList1.style.display = 'none';
        }
    }  
    </script> 
</head>
<body>
    <form id="form1" runat="server">
    <div> 
    <asp:CheckBox ID="CheckBox1" runat="server" Text="Items" onClick="forRentClicked()" /> 
        <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal" style="display:none;">
        <asp:ListItem>One</asp:ListItem>
        <asp:ListItem>Two</asp:ListItem>
        </asp:RadioButtonList>
</div> 

    </form>
</body>
</html>

 

output :

visible

How to "hide" or make "visible" in javascript when i "check or uncheck" a checkbox

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script language="javascript" type="text/javascript">
    function forRentClicked() {

        if (document.getElementById('<%=CheckBox1.ClientID%>').checked == true) {

            div1.style.display = 'block';

        }
        else {
           div1.style.display = 'none';
        }
    }  
    </script> 
</head>
<body>
    <form id="form1" runat="server">
    <div> 
    <asp:CheckBox ID="CheckBox1" runat="server" onClick="forRentClicked()" /> 
</div> 
<div id="div1"> 
    <asp:Label ID="Label1" runat="server" Text="Rental rate per week:"></asp:Label> 
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
</div> 
    </form>
</body>
</html>

 

Output:

visible1

Make Enter Button As Tab Key

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

    <script src="script/JScript.js" type="text/javascript"></script>

    <script type="text/javascript">
        function keypressed(e) {
            var intKey = (window.Event) ? e.keyCode:e.which;

            if (intKey == 13) {
                document.getElementById('<%=text2.ClientID %>').focus();
                return false;
            }

        }

        function keypressed2(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text3.ClientID %>').focus();
                return false;

            }
        }

        function keypressed3(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text4.ClientID %>').focus();
                return false;

            }
        }

        function keypressed4(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text5.ClientID %>').focus();
                return false;

            }
        }

        function keypressed5(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text6.ClientID %>').focus();
                return false;

            }
        }

        function keypressed6(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text7.ClientID %>').focus();
                return false;

            }
        }

        function keypressed7(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text8.ClientID %>').focus();
                return false;

            }
        }

        function keypressed8(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text9.ClientID %>').focus();
                return false;

            }
        }

        function keypressed9(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text10.ClientID %>').focus();
                return false;

            }
        }

        function keypressed10(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=DropDownList1.ClientID %>').focus();
                return false;

            }
        }

        function keypressed11(e) {
            var intKey = (window.Event) ? e.keyCode:e.which;
            if (intKey == 13) {

                document.getElementById('<%=Button1.ClientID %>').focus();
                return false;

            }
        }

        function Validation1() {
            if (document.getElementById('<%=DropDownList1.ClientID %>').value == "Select::") {
                alert('select DropDownList');
                       document.getElementById('<%=Button1.ClientID %>').focus();
                return false;
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:TextBox  onkeypress="return keypressed(event)"  id="text1" runat="server" Width="200px" ></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed2(event)" id="text2" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed3(event)" id="text3" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed4(event)" id="text4" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed5(event)" id="text5" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed6(event)" id="text6" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed7(event)" id="text7" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed8(event)" id="text8" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed9(event)" id="text9" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed10(event)" id="text10" runat="server" Width="200px"></asp:TextBox><br/>
     <asp:DropDownList ID="DropDownList1" runat="server" onkeypress="return keypressed11(event)">
        <asp:ListItem>Select::</asp:ListItem>
        </asp:DropDownList><br/>
     <asp:Button ID="Button1" runat="server" OnClientClick="return Validation1();" Text="Button" OnClick="Button1_Click" />
<asp:Label id="lblMsg" runat="server" forecolor="Red" text="* Username must be alphanumeric with no special characters"></asp:Label>
    </div>
    </form>
</body>
</html>

Monday, May 9, 2011

Enter Key Acts As Tab Key using Javascript

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script language="javascript" type="text/javascript">
function testing(event,number)

{
if( event.keyCode == 13 )

{
var wow = document.getElementById(number);

wow.focus();

}

}

</script>
    <title>Making enter key work as tab for Fire Fox</title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    &nbsp;<asp:Label ID="Label1" runat="server"
            Text="Make enter key work as tab for Fire Fox"></asp:Label>
        <table class="style1">
            <tr>
                <td>

                    <asp:TextBox ID="TextBox2" runat="server" onkeydown="testing(event,2)"
                        TabIndex="1"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <input id="2" type="text" tabindex="3" onkeydown="testing(event,3)" /></td>
            </tr>
            <tr>
                <td>

                    <input id="3" type="text" tabindex="2" onkeydown="testing(event,'ab')" /></td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="ab" runat="server" onkeydown="testing(event,'cd')"
                        TabIndex="4"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="cd" runat="server" onkeydown="testing(event,'ef')"
                        TabIndex="10"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:DropDownList ID="ef" runat="server" onkeydown="testing(event,'RadioButton1')">
                        <asp:ListItem>a</asp:ListItem>
                        <asp:ListItem>b</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:RadioButton ID="RadioButton1" runat="server" onkeydown="testing(event,'ListBox1')"/>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:ListBox ID="ListBox1" runat="server" onkeydown="testing(event,'TextBox1')"></asp:ListBox>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server" onkeyup="testing(event,'Button1')"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Button ID="Button1" UseSubmitBehavior="false" runat="server" Text="Button" Width="166px" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>