Text Box and Button Tools of Standard Tool Kits

Scope: To learn to use , Text Box and Button Tools of Standard Tool Kits installed with Visual Web Developer 2008 Express edition.

Step 1. Create new website

This step will show you how

Now add a "text box" and "button" from the toolbox, preferably within the division block.

Please note that the line break is what separates the text box and the button from each other.

Now click on the "Button", this will create a block of codes.

For this purpose, to show the use of the button, we add a label control.

 

Step 2

Coding

Default.aspx

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_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">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>My name is Anthoy Gonzalvez, I am a lone dove in this world; <br/>
<asp:TextBox ID="TextBox1" runat="server" Height="28px" Width="176px"></asp:TextBox><br/>
<asp:Button ID="Button1" runat="server" Text="Write " onclick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Clear "
onclick="Button2_Click" /><br/>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
 

Default.aspx.cs

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)
{

}

protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text += "<br/>" + TextBox1.Text;

}
protected void Button2_Click(object sender, EventArgs e)
{
Label1.Text = "";
TextBox1.Text="";

}
}
 

Step 3

Run time analysis

Here is what it should look like