HTML TextBox Example in ASP.NET using C#

HTML TextBox Example in ASP.NET using C#


Posted in : ASP.Net Posted on : December 8, 2010 at 5:14 PM Comments : [ 0 ]

In this article we will introduce with HTML TextBox control in ASP.NET using C#.

HTML Input(Text) Example Using in Asp.net

HTML Textbox be a part of HTML control in Asp.net ToolBox. HTML Input Textbox accept text input into define format. if use as in Password  <input type="Password'> in this condition textbox accept only masked (***) value otherwise Textbox accept user interred(string,float,int) value. Following Example: 1-we choose a HTML textbox that indicate for Hour. 2- choose option list that show option for Hour time convert into Minute or Second. 3- one choose Button for output display in Label.

HTML Text.aspx (Design Page):

HTML Text.aspx (source page):

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Text.aspx.cs" Inherits="Text" %>
<!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>
<style type="text/css">
.style1
{
font-family: Verdana;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 class="style1" style="color: #CC3300">
devmanuals.com</h2>
Inter Hour :
<input type="text" id="Time" runat="server" /><br />
Choose Option Minute/Second :
<select id="Change" runat="server" />
<br />
<br />
<input type="submit" value="Convert Time" id="Convert" runat="server" onserverclick="Convert_ServerClick" />
<br />
<br />
<div style="font-weight: bold" id="Output" runat="server">
</div>
</div>
</form>
</body>
</html>

HTML Text.aspx.cs (C# Code File):


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public partial class Text : System.Web.UI.Page
{
protected void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
Change.Items.Add(new ListItem("Minute", "60"));
Change.Items.Add(new ListItem("Second", "3600"));
}
}
protected void Convert_ServerClick(object sender, EventArgs e)
{
decimal calculate;
bool ok = Decimal.TryParse(Time.Value, out calculate);
if (ok)
{
ListItem item = Change.Items[Change.SelectedIndex];
decimal newAmount = calculate * Decimal.Parse(item.Value);
Output.InnerText = calculate.ToString() + " Hour Convert Time into = ";
Output.InnerText += newAmount.ToString() + " " + item.Text;
}
else
{
Output.InnerText = "Inter the Integer Type value in Textbox:";
}
}
}

Output:

Download Source Code
Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics