Category Archives: ASP.Net Controls

How to use MultiView Control in ASP.Net

In previous asp.net server control post we had discussed about DropDownList Control and ListBox Control and CheckBox Control and RadioButton Control and Adrotator Control and FileUpload Control and TextBox Control.

ASP.Net MultiView Control

MultiView Control is an asp.net web server control. Multiview Control is a same as Tab control. If you want make a complex designing on one web forms then you have to use multiview control.

MltiView control is a container of several view control. In a multiview control there are many view control for designing separation of view for user.

The View control is a container of several web server controls. Using the multiview control we can feel the multiple page view design on a single web page.

We can also say multiview control allow user to create different view on single web page.There are many view control in a multiview control, each view control has a some web server control for design web page. we can see single view at a time on web page by specify the ActiveViewIndex property of multiview control.

All view control assign automatically index to all it, the index always start from zero. The first view1 index is zero, second is one and so on….
If we want to display first view on web page, then we need to write MultiView1.ActiveViewIndex=0.

Here we take an example to understand how to use  multiview control in asp.net c#.

First create a asp.net web application and design web forms like below.
Design the web form with a multiview control and three view control within it along with three button control.

The HTML Design code for multiview is :

 

Example of MultiView Control in ASP.Net

After Design asp.net web forms take a multiview control on web forms from toolbox.

How to use MultiView control in ASP.Net C#.

How to use MultiView control in ASP.Net C#.

Now, add some view control in multiview control as per your needs, here we use three view control to understand this multiview control example. The three view View1, View2 and View3, after taking views on web page design the all view control with some web server control.

How to use MultiView control in ASP.Net C#.

How to use MultiView control in ASP.Net C#.

Below screen shows the final designing of web page. here we take three view control in multiview control and design all three view control as per our requirement. There are three button on web page for display view control on page.

How to use MultiView control in ASP.Net C#.

How to use MultiView control in ASP.Net C#.

Here, is the out put of multiview example, when we run the application, by default we can not see any view on web page.  we just see the three button control on web page for display the view control.

How to use MultiView control in ASP.Net C#.

How to use MultiView control in ASP.Net C#.

When we click to button View1 then the view1 is displaying on web page.

Here we need to write below code for display view1 in button control.

How to use MultiView control in ASP.Net C#.

How to use MultiView control in ASP.Net C#.

When we click button View2 then the view2 is displaying on web page.

Here we need to write below code for display view2 in button control.

How to use MultiView control in ASP.Net C#.

How to use MultiView control in ASP.Net C#.

When we click to button View3 then the view3 is displaying on web page.

Here we need to write below code for display view3 in button control.

How to use MultiView control in ASP.Net C#.

How to use MultiView control in ASP.Net C#.

 

Here, is the code behind C# code for MultiView Control all three buttons controls.

 VB.Net Code for MultiView Control Example:

 

ListBox Control in ASP.Net

In previous asp.net server control post we had discussed about MultiView Control and DropDownList Control and FileUpload Control and CheckBox Control and RadioButton Control and Adrotator Control and TextBox Control.

ASP.Net ListBox Control

ListBox control is an asp.net web server control. ListBox control used to store the multiple items and allow user to select multiple item from listbox control. ListBox control is same as dropdownlist control.

The dropdownlist control allow user to select maximum only one item at a time, on other hand listbox control allow user to select multiple items same time. so we can also say listbox is a multi row selection box control.

In a ListBox control there is a SelectionMode property to change the mode of section from single to multiple. By default listbox control selection mode is single if you want to select multiple items from listbox, then just change the SelectionMode property to multiple.

ListBox Control Example in ASP.Net C#

How to use ListBox control in asp.net C#.

How to use ListBox control in ASP.Net C#.

How to use ListBox control in asp.net C#.

Some important Properties of ListBox Control.

Items : Items property used to add item into the listbox control. It is indicate the collection of items in the listbox.

There are main two things to consider while adding new item in listbox control.
Each Item of listbox control contain Text and Value attributes.

At time of adding new item in listbox we need to give two things text and values for each item.

Text : Text Property specify the Text display in the listbox.

Value : The value property is invisible value, but we can get the value while programming. Each item has a text and value with in it.

For add new items in listbox control go to the lsitbox Items property and add some items show like below screen.

How to add new items in listbox control in asp.net.

How to add new items in listbox control in asp.net.

If you click the items property of listbox you have a below screen to add some items. Here click Add button to add items to listbox.

How to add new items in listbox control in asp.net.

How to add new items in listbox control in asp.net.

Add some items with Text and Value of items and Add button to add items to listbox control.

How to add new items in listbox control in asp.net.

How to add new items in listbox control in asp.net.

The result of the listbox control with four items.

How to add new items in listbox control in asp.net.

How to add new items in listbox control in asp.net.

There are other some important properties of listbox :

ListBox1.Items.Count = Return the total count of items in the listbox.
ListBox1.Items.Add(“ItemName”) = Add the new item in to the listbox control.
ListBox1.Items.Insert(int index, “ItemName”) = Add the new item at specific position in listbox control.
ListBox1.Items.Remove(“ItemName”) = Remove the item from the listbox control.
ListBox1.Items.RemoveAt(int index) = Remove the item from the listbox at desired position index.
ListBox1.Items.Clear() = Clear all the items from listbox control.
ListBox1.SelectedItem.Text = Returns the Text value of selected item of the listbox.
ListBox1.SelectedValue = Returns the Value property of the selected item of the listbox.

ListBox1.SelectedIndex = Returns the Index of selected item of listbox. (Index always start from Zero).

Here, is the code for bind listbox control from database.
ListBox1.DataSource = DataTable OR DataSet
ListBox1.DataTextField = Bind the Text to listbox (It is visible in listbox)
ListBox1.DataValueField  = Bind the Value to listbox (It is Invisible in listbox)
ListBox1.DataBind();

 

Lets take an example to understand all the properties of listbox control in asp.net c#.
Design the asp.net web page like below:
Here is the HTML Code for design asp.net web page:

Here, we have seven button control for understand all property of listbox control.

ListBox1.Items.Count

Below example show the total number of item count in listbox control.

Count Total Number of items in listbox control in asp.net

Count Total Number of items in listbox control in asp.net

 

ListBox1.SelectedItem.Text

Example : How to get selected item from listbox control in asp.net.

Get Selected Item from listbox control in asp.net c#

Get Selected Item from listbox control in asp.net c#

ListBox1.SelectedValue

Example : How to get Selected Value from listbox control in asp.net.

Get Selected Value from listbox control in asp.net c#

Get Selected Value from listbox control in asp.net c#

 

ListBox1.SelectedIndex

Example: Get Selected Index in listbox control in asp.net.

Get Selected Index from listbox control in asp.net c#

Get Selected Index from listbox control in asp.net c#

 

ListBox1.Items.Clear()

Example : Clear all items in listbox control.

How to clear all items from listbox in asp.net c#.

How to clear all items from listbox in asp.net c#.

 

ListBox1.Items.Add(“text”);

Example : Add new item in listbox control.

How to Add new items in  listbox in asp.net c#.

How to Add new items in listbox in asp.net c#.

 

ListBox1.Items.Remove(“text”)

Example : Remove items from listbox control.

How to Remove Item from listbox in asp.net c#.

How to Remove Item from listbox in asp.net c#.

 

ListBox1.Items.Insert(int index, “text”);

Example : Add new item at specific location in listbox control. The index is the indicate the location of newly added item in listbox control.

 

ListBox1.Items.RemoveAt(int index)

Example : Remove items from listbox control at specify the index location. The index start from zero.

Here is the code behind c# code :

 

DropDownList Control in ASP.Net

In previous asp.net server control post we had discussed about MultiView Control and ListBox Control and FileUpload Control and CheckBox Control and RadioButton Control and Adrotator Control and TextBox Control.

ASP.Net DropDownlList Control

The DropDownList control is asp.net web server control. we can use dropdownlist control for hold group of items.

The dropdownlist control is used to store the multiple items and allow user to select only one item from it.

The dropdownlist control is also known as combo box control. In dropdownlist control we can store multiple items but we can select only one item at a time, that’s why it is also known as Single Row Selection Box.

In asp.net there are main two control to store multiple items with it, the dropdownlist and the listbox control.

Learn about listbox control to click here…

There is only SelectionMode difference between dropdownlist control and listbox control. The dropdownlist has no SelectionMode, so we can not selection multiple item in dropdownlist.

DropDownList Control Example in ASP.Net C#

Here, we understand the dropdownlist control with an asp.net example.

Create a new web application in asp.net with a web forms. below screen shows how to take dropdownlist control on web page from toolbox.

How to use DropDownList control in ASP.Net c#.

How to use DropDownList control in ASP.Net c#.

Now, for add new items in dropdownlist go to the Items property shows like below asp.net figure.

How to use DropDownList control in ASP.Net c#.

How to use DropDownList control in ASP.Net c#.

In dropdownlist control all the elements are known as items of dropdownlist, and each items consist with text and value attributes.

If we add items in to dropdwonlist control we must provide Text and Value for each items.

Text = Text Property specify the Text display in the dropdownlist.

Value = The value property is invisible value, but we can get the value while programming.

How to use DropDownList control in ASP.Net c#.

How to use DropDownList control in ASP.Net c#.

Here is the html code of dropdownlist control with five items.

How to use DropDownList control in ASP.Net c#.

How to use DropDownList control in ASP.Net C#.

There are other some important properties of dropdownlist:

DropDownList1.Items.Count = Return the total count of items in the dropdownlist.
DropDownList1.Items.Add(“ItemName”) = Add the new item in to the dropdownlist control.
DropDownList1.Items.Insert(int index, “ItemName”) = Add the new item at specific position in dropdownlist control.
DropDownList1.Items.Remove(“ItemName”) = Remove the item from the dropdownlist control.
DropDownList1.Items.RemoveAt(int index) = Remove the item from the dropdownlist at desired position index.
DropDownList1.Items.Clear() = Clear all the items from dropdownlist control.
DropDownList1.SelectedItem.Text = Returns the Text value of selected item of the dropdownlist.
DropDownList1.SelectedValue = Returns the Value property of the selected item of the dropdownlist.

DropDownList1.SelectedIndex = Returns the Index of selected item of dropdownlist. (Index always start from Zero).

Here, is the code for bind dropdownlist control from database.
DropDownList1.DataSource = DataTable OR DataSet
DropDownList1.DataTextField = Bind the Text to dropdownlist(It is visible in dropdownlist)
DropDownList1.DataValueField  = Bind the Value to dropdownlist(It is Invisible in dropdownlist)
DropDownList1.DataBind();

 

DropDownList1.Items.Count

Below example show the total number of item count in dropdownlist control.

How to get total number of items count in dropdownlist in asp.net

How to get total number of items count in dropdownlist in asp.net

DropDownlList1.SelectedItem.Text

Example : How to get selected item from dropdownlist control in asp.net.

Get SelectedItem from dropdownlist control in asp.net

Get SelectedItem from dropdownlist control in asp.net C#

DropDownList1.SelectedValue

Example : How to get Selected Value from dropdownlist control in asp.net.

Get SelectedValue from dropdownlist control in asp.net

Get SelectedValue from dropdownlist control in asp.net C#.

DropDownList1.SelectedIndex

Example: Get Selected Index in dropdownlist control in asp.net.

SelectedIndex in dropdownlist control in asp.net C#

SelectedIndex in dropdownlist control in asp.net C#

DropDownList1.Items.Clear()

Example : Clear all items in dropdownlist control.

How to use clear() in dropdownlist control in asp.net C#.

How to use clear() in dropdownlist control in asp.net C#.

DropDownList1.Items.Add(“text”);

Example : Add new item in dropdownlist control.

How to add new item in dropdownlist control in asp.net C#.

How to add new item in dropdownlist control in asp.net C#.

DropDownList1.Items.Remove(“text”)

Example : Remove items from dropdownlist control.

How to Remove item from dropdownlist control in asp.net C#.

How to Remove item from dropdownlist control in asp.net C#.

DropDownList1.Items.Insert(int index, “text”);

Example : Add new item at specific location in dropdownlist control. The index is the indicate the location of newly added item in dropdownlist control.

 

DropDownList1.Items.RemoveAt(int index)

Example : Remove items from dropdownlist control at specify the index location. The index start from zero.

The C# code behind code for all buttons click events.

 

AdRotator Control in ASP.Net

In previous asp.net server control post we had discussed about MultiView Control and ListBox Control and FileUpload Control and CheckBox Control and RadioButton Control and DropDownList Control and TextBox Control.

ASP.Net AdRotator Control

The AdRotator is one of the rich web server control of asp.net. AdRotator control is used to display a sequence of advertisement images as per given priority of image.

Adrotator control display the sequence of images, which is specified in the external XML file. In a xml file we indicate the images to display with some other attributes, like  image impressions, NavigateUrl, ImageUrl, AlternateText.

In a Adrotator control images will be changed each time while refreshing the web page.

AdRotator Control Example in ASP.Net

Step 1 – Open the Visual Studio –> Create a new empty Web application.

Step 2 – Create a  New web page for display AdRotator control.

step 3 – Drag and drop AdRotator Control on web page from toolbox.

step 4 – go to Add New Item –> Add New XML File in project for write advertisement detail.

step 5 – Assign XML File to AdvertisementFile Property of AdRotator control.

Now, let’s understand the adrotator control with an asp.net example.

Adrotator Control in ASP.Net C#

Create a asp.net web application and take an adrotator control on web forms like below:

How to use Adrotator control in asp.net C#.

How to use Adrotator control in asp.net C#.

Now, Add new XML file by going to add new item menu.

How to use Adrotator control in asp.net C#.

How to use Adrotator control in asp.net C#.

Select XML file, assign any name for xml file and click Add button to add new xml file.

How to use Adrotator control in asp.net C#.

How to use Adrotator control in asp.net C#.

write below code for advertisement in xml file

The XML file contain the advertisement information.

ImageUrl describe the path of image which is display in adrotator.

Impressions describe the display rate of images or priority of image.

Advertisement XML File for Adrotator Control

Now, assign the XML file to adrotator control by AdvertisementFile property of adrotator control.

How to use Adrotator control in asp.net C#.

How to use Adrotator control in asp.net C#.

 

How to use Adrotator control in asp.net C#.

How to use Adrotator control in asp.net C#.

 

How to use Adrotator control in asp.net C#.

How to use Adrotator control in asp.net C#.

 

How to use Adrotator control in asp.net C#.

How to use Adrotator control in asp.net C#.

RadioButton Control in ASP.Net

In previous asp.net server control post we had discussed about MultiView Control and ListBox Control and FileUpload Control and Adrotator Control and CheckBox Control and DropDownList Control and TextBox Control.

ASP.Net RadioButton Control

Radiobutton is a asp.net web server control. Radiobutton is used to allow user to select a single radiobutton from group of radiobutton. In a asp.net generally we use more than one radiobutton and select only one radiobutton at a time from all the radiobutton control. on other hand in checkbox control we can check and uncheck multiple check box at a time.

RadioButton Control ASP.Net Example

Now take an asp.net radiobutton example to understand more about radiobutton control.

How to use RadioButton control in asp.net c#.

How to use RadioButton control in asp.net c#.

Here are some important properties of radiobutton control in asp.net.
Checked = true/false, Indicate the radiobutton control is checked or unchecked.
GroupName =  GroupName property used to make a group of radiobutton. If we assign same value to more than one radiobutton then we can select only one radiobutton from that group of radiobutton.
How to use RadioButton control in asp.net c#.

How to use RadioButton control in asp.net c#.

HTML Design code for asp.net web forms:

How to use RadioButton control in asp.net c#.

How to use RadioButton control in asp.net c#.

code behind c# code :

How to use RadioButton control in asp.net c#.

How to use RadioButton control in asp.net c#.

CheckBox Control in ASP.Net

In previous asp.net server control post we had discussed about MultiView Control and ListBox Control and FileUpload Control and Adrotator Control and RadioButton Control and DropDownList Control and TextBox Control.

ASP.Net CheckBox Control

CheckBox control is an asp.net web server control. CheckBox control visually as square on web forms. The Checkbox control allow user to check square or uncheck square.

In CheckBox control check and uncheck checkbox specify by the checked property of check box true or false.

If checkbox control square ticked then checked = true and unchecked then checked=false.

We can drag the checkbox control from toolbox and drop it to on web forms shows like below. Checkbox control allow user to do either checked(tick) or unchecked (untick) the checkbox control in asp.net.

CheckBox Control ASP.Net C# Example

let’s take a simple asp.net checkbox exmaple to understand checkbox checked or unchecked.

ASP.Net CheckBox Control

ASP.Net CheckBox Control

 

Here is the html design source code of asp.net web page.

After design asp.net web page with a checkbox, a button and a label control shows like below screen.

In below asp.net figure we have not checked the checkbox and click on select button then we get answer in label control like Checkbox is unchecked.

ASP.Net CheckBox Control

ASP.Net CheckBox Control

Now, check the checkbox control and then click button to display message in label like CheckBox is Checked.

Here is the c# code behind code for button click event for check whether checkbox is checked or unchecked.

ASP.Net CheckBox Control

ASP.Net CheckBox Control

There is other important property of checkbox is Autopostback.

Autopostback means when we receive request from user and go to server with request and proceed the request on server and get back to user with response as a result, the all round trip known as postback.

If we set Autopostback = true on checkbox then the checkbox control CheckedChanged event enable for user, means we go to the code behind while check or uncheck checkbox control.

below example shows how autopostback will work in checkbox control.

Design asp.net web page with two checkbox control along with a label control.

Set both checkbox contorl AutoPostBack = true.

CheckBox Control AutoPostBack ASP.Net Example

The html design source code is:

Here, we can check only one checkbox at a time, if we check one checkbox and try to check other checkbox the first checkbox control automatically unchecked by using the checkbox_CheckedChanged events.

below screen shows the design out put of asp.net checkbox autopostback example.

AutoPostBack in checkbox control in asp.net c#

AutoPostBack in checkbox control in asp.net c#

write below code on code behind page for both checkbox CheckedChanged events.

In below example when we  check the Red checkbox control then RED CheckBox is checked message display on label control. If we check green checkbox control then the Red checkbox control automatically unchecked and the label control display with Green CheckBox is checked message.

AutoPostBack in checkbox control in asp.net c#

AutoPostBack in checkbox control in asp.net c#

In below screen shows the Green checkbox control is checked, the label display message as Green CheckBox is checked.

AutoPostBack in checkbox control in asp.net c#

AutoPostBack in checkbox control in asp.net c#

I hope you like this checkbox control asp.net post.

FileUpload Control in ASP.Net C#

In previous asp.net server control post we had discussed about MultiView Control and DropDownList Control and ListBox Control and CheckBox Control and RadioButton Control and Adrotator Control and TextBox Control.

ASP.Net FileUpload Control

In this asp.net tutorial i will explain how to upload file or image from local drive to website using fileupload control.

The fileupload control in asp.net used to upload any file like image, document file, zip file ..etc to asp.net website.

Here, we understand how to upload file using fileupload control with an asp.net example.

first create a new asp.net empty website, add new web forms Default.aspx in asp.net website and drag and drop fileupload control from toolbox to default page.

FileUpload Control Example in ASP.Net

Step 1 – Open the Visual Studio –> Create a new empty Web application.

Step 2 – Create a  New web page for display FileUpload control.

Step 3 – Drag and drop FileUpload control on web page along with one Button control from Toolbox.

Step 4 – write server side code in  button click event for upload image using FileUpload control.

 

ASP.Net FileUpload Control Example

ASP.Net FileUpload Control

ASP.Net FileUpload Control

Here is the html source code for above asp.net web page.

Now, add new folder for save uploaded image by right click on website project and select New Folder shows like below. give name img to newly created folder in asp.net. when we upload file or image using fileupload control the file uploaded in to img folder in our website.

ASP.Net FileUpload Control

ASP.Net FileUpload Control

Here, is the asp.net fileupload control example design layout. here we took one fileupload control, a button control and a label control for design web page. fileupload control brows and select the image or file from our local drive fro upload and the button control upload the file to desired folder in out website. In this fileupload control example we make img folder for save file on website.

ASP.Net FileUpload Control

ASP.Net FileUpload Control

Here, we can see the output when we browse the file for upload. just select any file from local drive and select open button to select the file for upload.

ASP.Net FileUpload Control

ASP.Net FileUpload Control

After selecting file for upload click the Upload button to upload file to desired location at website.

Here, is the button click event code for upload file to specific folder on website.

ASP.Net FileUpload Control

ASP.Net FileUpload Control

If you don’t select any file and click the upload button you will get error message like Select image first dhows in below asp.net screen.

ASP.Net FileUpload Control

ASP.Net FileUpload Control

FileUpload Control Example

Let’s take an another fileupload control example to understand more about fileupload control in asp.net.

Here, we design an asp.net web forms with fileupload control, a button and image control for displaying image.

In this example we upload the image file using fileupload control and displaying that image on image control at same time of uploading image on asp.net web application.

Here is the html source code for asp.net web page design :

The output of design code is :

ASP.Net FileUpload Control Example

ASP.Net FileUpload Control Example

Here is the upload button c# code:

ASP.Net FileUpload Control Example

ASP.Net FileUpload Control Example

 

ASP.Net FileUpload Control Example

ASP.Net FileUpload Control Example

TextBox Control in ASP.Net

In previous asp.net server control post we had discussed about MultiView Control and ListBox Control and FileUpload Control and CheckBox Control and RadioButton Control and DropDownList Control and Adrotator Control.

ASP.Net TextBox Control

Textbox control is a most usable web server control in asp.net.
TextBox control is a rectangular box which is allow user to input some text value. If we want to get some text from users then we have to use textbox control in asp.net.In simple word the textbox control is a place where user can input some text on asp.net web page.

 

How to use TextBox control in ASP.Net C#

To understand more about asp.net textbox control let’s take an example.

First create new asp.net web application with a default.aspx web forms.

Drag and drop the textbox control from toolbox to web page.

ASP.Net TextBox control

ASP.Net TextBox control

We can get the content of textbox control using Text property. Text property is used to get text displaying in textbox control.

Here is the syntax of Text property of textbox control.

ASP.Net TextBox control

ASP.Net TextBox control

Properties of TextBox Control

ID – ID is the identification name of textbox control.
Text – Display text in the textbox control.
BackColor – Set the background color of textbox control.
CssClass  – stylename (used to apply style on textbox control.)
Enable – true/false (used to enable and disable control.)
Enable Theming – true/false (used to enable and disable effect of theme on textbox control)
Visible – true/false (used to hide or visible control on web page)
CausesValidation – true/false (used to enable and disable validation control effect on textbox control)
ToolTip – Display the text on control when mouse over on textbox control.
TabIndex – manage the order of tab.

Here are some important properties of TextBoxControl

MaxLength – used to define the length of character in textbox.
ReadOnly – true/false (Readonly property used to enable/disable modification of text)
TextMode – Single / Multiline / Password

ASP.Net TextBox Example

write a text in textbox control programmatically on button click event in asp.net.

write below C# code on button click event at code behind page.

ASP.Net TextBox control

ASP.Net TextBox control

Now, for understand other property of textbox, check the below asp.net textbox example.

Here is the html design source code of textbox example :

Below screen is a out put of design of textbox control example.

ASP.Net TextBox Control Example

ASP.Net TextBox Control Example

TextBox MexLength

TextBox1.MaxLength – MexLength property used to set character length inputted by user. In MexLength we can set any integer value, if we set textbox mexlength = 5 then we can only input 5 character in textbox when run the asp.net website.

In below textbox mexlength example we set mexlength property = 8, so we can input only 8 character in textbox shows like below figure.

Here is code for set mexlength property programmatically in asp.net.

TextBox MexLength  - ASP.Net

TextBox MexLength – ASP.Net

TextBox ReadOnly

TextBox ReadOnly property used to enable or disable modification of text in textbox control in asp.net.

Here, we set Boolean value true or false for textbox readonly. If textbox readonly=true then we can only read the content of textbox, we can’t edit or modifying text content of textbox.

In below example we set textbox ReadOnly = true

TextBox ReadOnly - ASP.Net

TextBox ReadOnly – ASP.Net

TexBox Background Color

Textbox BackColor – The BackColor is used to change the background color of textbox control.

Textbox BackColor - ASP.Net

Textbox BackColor – ASP.Net

TextBox Border Style

Textbox border – If we make a border of textbox control, then we need to set textbox borderstyle, textbox borderwidth and textbox bordercolor.

TextBox Border - ASP.Net

TextBox Border – ASP.Net

TextBox Password Mode

TextBox Password Mode – If we set textbox textmode equal to password mode, then the inputted text will be converted to password (*) character.

TextBox Password Mode - ASP.Net

TextBox Password Mode – ASP.Net

TextBox SingleLine Mode

The basic by default mode of textbox is single line. The normal textbox is single line textbox.

TextBox SingleLine Mode - ASP.Net

TextBox SingleLine Mode – ASP.Net

TextBox Font Color

Textbox ForeColor property is used to change the text color of textbox.

TextBox Font Color - ASP.Net

TextBox Font Color – ASP.Net

TextBox Bold Font

The Textbox font bold is used to display bold font text in textbox.

TextBox Width - ASP.Net

TextBox Width – ASP.Net

TextBox Width

TextBox Width - ASP.Net

TextBox Width – ASP.Net

Image Control in ASP.Net

ASP.Net Image Control

ImageButton Control in ASP.Net

ASP.Net ImageButton Control

In previous  asp.net post we have learned about Simple Push Button and Link Button Control.

Download Example
asp.net example

In this asp.net tutorials we will learn how to use LinkButton control in asp.net.

There are three type of button in asp.net.
1. Simple Push Button
Simple Push  Button displays text on a button control.

2. Link Button
Link Button displays text that looks like a link or hyperlink.

3. Image Button
– Image Button displays an image on a button control.

ImageButton Control Example in ASP.Net.

Step 1 – Open the Visual Studio –> Create a new empty Web application.

Step 2 – Create a New web page for display Imagebutton on it.

Step 3 – Drag and drop ImageButton control on web page from Toolbox.

Step 4 – Set ImageUrl property of ImageButton Control for display image on control.

Step 5 – For Redirect other page set PostBackUrl Property to destination web page name.

Step 6 – For write code on Imagebutton control go to Click events of Imagebutton control.

ASP.Net ImageButton Control Example:

The ImageButton code is like:

<asp:ImageButton ID=”ImageButton1″ runat=”server” />

Some important property of ImageButton Control:

ID – identification of ImageButton control
ImageUrl – set image path to display image on image button control.
AlternateText – AlternateText text display when image can not display on web page.
PostBackUrl – Path of the page when redirect while click the Image button.
OnClientClick – write JavaScript or any client side script code function name.

Example of Imagebutton Control in ASP.Net :

ASP. Net ImageButton Control

ASP. Net ImageButton Control

 

ASP.Net ImageButton Control

ASP.Net ImageButton Control

After drag and drop ImageButton control on web page set ImageUrl property for display image on imagebutton control in asp.net.

Set the image page for display image on ImageButton Control in asp.net.

ASP.Net ImageButton Control

ASP.Net ImageButton Control

Select the iamge you want to display on imagebutton control in asp.net.

ASP.Net ImageButton Control

ASP.Net ImageButton Control

Design asp.net web form with ImageButton Control and Label Control look like below screen.

write below code in Imagebutton click event for display message on label control in asp.net

 protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Label1.Text = “Meera Academy”;
}

ASP.Net ImageButton Control

ASP.Net ImageButton Control

 

ASP.Net ImageButton Control

ASP.Net ImageButton Control

LinkButton Control in ASP.Net.

ASP.Net LinkButton Control

In previous  asp.net post we have learned about Simple Push Button and Image Button Control.

In this asp.net tutorials we will learn how to use LinkButton control in asp.net.

There are three type of button in asp.net.
1. Simple Push Button
Simple Push  Button displays text on a button control.

2. Link Button
– Link Button displays text that looks like a link or hyperlink.

3. Image Button
Image Button displays an image on a button control.

LinkButton Control Example in ASP.Net.

Step 1 – Open the Visual Studio –> Create a new empty Web application.

Step 2 – Create a New web page for display Linkbutton on it.

Step 3 – Drag and drop LinkButton control on web page from Toolbox.

Step 4 – Set Text property of LinkButton Control

Step 5 – For Redirect other page set PostBackUrl Property to destination web page name.

Step 6 – For write code on Linkbutton control go to Click events of Linkbutton control.

ASP.Net LinkButton Control Example:

The Link Button code is like:

<asp:LinkButton ID=”LinkButton1″ runat=”server”>LinkButton</asp:LinkButton>

Some important property of LinkButton Control:

ID – identification of LinkButton control
Text – Display text on LinkButton like hyperlink.
PostBackUrl – Path of the page when redirect while click the button.
OnClientClick – write JavaScript or any client side script code function name.

Example of button Control in ASP.Net :

ASP.Net LinkButton Control

LinkButton Control in ASP.Net

 

ASP.Net LinkButton Control

ASP.Net LinkButton Control

 

Design asp.net web form with LinkButton Control and Label Control look like below screen.

write below code in Linkbutton click event for display message on label control in asp.net

 protected void LinkButton1_Click(object sender, EventArgs e)
{
Label1.Text = “Meera Academy”;
}

ASP.Net LinkButton Control

ASP.Net LinkButton Control

 

ASP.Net LinkButton Control

ASP.Net LinkButton Control

 

HyperLink Control in ASP.Net

ASP.Net HyperLink Control

In this asp.net tutorials we will lean how to use HyperLink control in ASP.Net.

HyperLink  is an asp.net web server control. we can display a  hyperlink on a web page by adding a hyplerlink control on asp.net web page.
HyperLink control used to navigate user to anther page or on the same page.
The main property  of hyperlink control is NavigateUrl. The NavigateUrl property of hyperlink control store the address of destination page.

ASP.Net HyperLink Control – HyperLink control is used to redirect user to other page in asp.net. In asp.net link one web forms to other using hyperlink control.

The HyperLink control display both as text and as image by specifying Text or ImageUrl property of hyperlink control.
If we set any image in ImageUrl property of hyperlink control then the hyperlink display image on it.if we set any text value in Text Property of hyperlink control then the hyperlink control display as text link.

Here we will understand hyperlink control with an asp.net example.

HyperLink Control Example in ASP.Net.

Step 1 – Open the Visual Studio –> Create a new empty Web application.

Step 2 – Create two New web page one for  display hyperlink and other for navigate to it.

Step 3 – Drag and drop HyperLink control on web page from Toolbox.

Step 4 – Set Text property of Hyperlink Control

Step 5 – Set NavigateUrl Property to destination web page name.

Here is the HTML code of HyperLink Control.

<asp:HyperLink ID=”HyperLink1″ runat=”server” NavigateUrl=”~/Default2.aspx”>Redirect Second Page</asp:HyperLink>

First Create asp.net web application with two web forms.

ASP.Net HyperLink Control

ASP.Net HyperLink Control

Create New web page and drag and drop HyperLink Control on web page from toolbox. below figure we can see the we have HyperLink control in asp.net web page.

ASP.Net HyperLink Control

ASP.Net HyperLink Control

Set the HyprLink control Text property  value to ‘Redirect Second Page’ or anything else what you like display on hyperlink.

ASP.Net HyperLink Control

ASP.Net HyperLink Control

Now, Set the NavigateUrl property of HyperLink control. write path or name of destination page where we want to redirect when click the hyperlink control.

ASP.Net HyperLink Control

ASP.Net HyperLink Control

Browse and select destination page and click OK button to set NavigateUrl of HyperLink control.

ASP.Net HyperLink Control

ASP.Net HyperLink Control

Below screen show we have set both Text and NavigateUrl property of hyperlink  control in asp.net.

ASP.Net HyperLink Control

ASP.Net HyperLink Control

The output of hyperlink control example in asp.net. when we click on Redirect Second Page link it will redirect us to next page which already assigned in NavigateUrl property of hyperlink control.

ASP.Net HyperLink Control

ASP.Net HyperLink Control

 

ASP.Net HyperLink Control

ASP.Net HyperLink Control

I hope you will like this asp.net hyperlink control example.