asp.net 2.0

How to Create a Custom Control in ASP.NET

If none of the existing ASP.NET server controls meet your requirements, then you can create a custom control by deriving from one of the base control classes. This Web Forms ASP.NET tutorial will show you how to achieve this.

Adding Custom Control to the Toolbox

1. Create a test Web Forms page. (WebForm1)
2. Using Tools menu, click Add/Remove Toolbox Items.
3. …

Learn more

How to disable a button after click in ASP.NET

This is a very common scenario when you would like to disable button after click, so the user could not click it again if you need some time to do some task which takes longer time to be executed.

Disable a button after click in ASP.NET before the PostBack

If you would like to disable button to do some task, …

Learn more

How to make the TextBox readonly or disabled in ASP.NET

You can make the TextBox control readonly by setting its ReadOnly property to true. You can set this property in the .aspx page which contains the TextBox control, or programmatically from the code-behind. The next test .aspx page shows this:

ReadOnlyTextBox.aspx

<%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”ReadOnlyTextBox.aspx.cs”

Inherits=”TextBoxSamplesVC.ReadOnlyTextBox” %>

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

<html xmlns=”https://www.w3.org/1999/xhtml”>

<head runat=”server”>

Learn more

How to render a password type textbox in ASP.NET

You can render the TextBox control to as password type by setting its TextMode property to Password.

TextBoxAsPassword.aspx

<%@ Page Language=”vb” AutoEventWireup=”false” CodeBehind=”TextBoxAsPassword.aspx.vb”

Inherits=”TextBoxSamplesVB.TextBoxAsPassword” %>

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

<html xmlns=”https://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title>Password type TextBox</title>

</head>

<body>

<form id=”form1″ runat=”server”>

<div>

<asp:TextBox ID=”tbPassword” runat=”server” TextMode=”Password”></asp:TextBox>

</div>

</form>

</body>

</html>

Related TutorialsHow to preserve member variables for an ASP.NET …

Learn more

How to write encoded text on the web page in ASP.NET

When you want to write encoded text on the web page you should use the Literal control, because it does support a property that is not supported by the Label control: the Mode property. The property enables you to encode HTML content and accept any of the following three values:

–  PassThrough—Displays the contents of …

Learn more

How to associate a Label with a TextBox or other Form control in ASP.NET

The next code shows how you can attach an asp:Label control with the asp:TextBox. In this case when the user clicks the Label the application will focus on the TextBox.

 

TestAssociate.aspx

<%@ Page Language=”vb” AutoEventWireup=”false” CodeBehind=”TestAssociate.aspx.vb” Inherits=”TextChange.TestAssociate” %>

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

<html xmlns=”https://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title>Associate a Label with a TextBox</title>

</head>

<body>

<form id=”form1″ runat=”server”>

Learn more

How to change the text of the Label control from the code-behind in VB.NET

TestPage (.aspx)

<%@ Page Language=”vb” AutoEventWireup=”false” CodeBehind=”TestPage.aspx.vb” Inherits=”TestChange.TestPage” %>

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

<html xmlns=”https://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title>Change the text of the Label control from the code-behind</title>

</head>

<body>

<form id=”form1″ runat=”server”>

<div>

<asp:Label ID=”LabelTest” runat=”server” Text=”My test label”></asp:Label>

</div>

</form>

</body>

</html>

Test page code-behind (.vb)

‘TestPage.apsx.vb

Public Class TestPage

Inherits System.Web.UI.Page

Protected Sub …

Learn more