Skip to main content

Posts

Showing posts from March, 2009

asp.net - How to use LinkButton click event

Click event in LinkButton control LinkButton is an ASP.NET web server control. The LinkButton server control renders a hyperlink-style button control on the web page. Though it looks like a hyperlink it has the same functionality as a Button control. By default, a LinkButton control is a submit Button. We also can use it as a command button. When we use LinkButton control as a regular submit button, we can provide an event handler for its Click event. Submit button simply posts the web page back to the server. This Click event allows us to programmatically control the action performed the submit Button (LinkButton) is clicked. The LinkButton Click event occurs when the LinkButton control is clicked. The click event is commonly used when no command name is associated with the LinkButton control. The LinkButton OnClick method raises the Click event of the LinkButton control. The OnClick method required a parameter named e. this parameter type is System.EventArgs ...

asp.net - How to submit a form with a LinkButton

Submit an asp.net page by LinkButton control LinkButton is an ASP.NET web server control. LinkButton control display as a hyperlink-style Button control on the web page. LinkButton server control has the same appearance as a hyperlink control but it has the same functionality as a regular button control. We can render LinkButton control as a Submit button or as a Command button on the web page. So we can submit an ASP.NET page to the web server by LinkButton control. Submit button does not have a command name associated with it. By default, LinkButton control is a submit Button that simply posts the web page back to the server. We can provide an event handler for the LinkButton Click event to programmatically control the action performed when the submit Button is clicked. The LinkButton Click event occurs when the LinkButton control is clicked. The following ASP.NET C# example code demonstrates to us how can we submit an ASP.NET page to the w...

asp.net - How to change Label width programmatically

Change Label width programmatically The Label class Represents a label control, which displays text on a Web page. The asp.net developers can use the Label control to display text in a set location on the web page. Unlike static text, asp.net c# developers can customize the displayed text through the Text property. The following asp.net c# tutorial code demonstrates how we can programmatically change a Label control’s width. Here we used the Label web server control’s Width property to change its width programmatically. The Label control Width property gets or sets the width of the Web server control. The Width property value is a Unit that represents the width of the Label control. The default value of this property is Empty. The Unit structure represents a length measurement. The Label control’s Width property throws ArgumentException if the width of the Web server control was set to a negative value. So finally, the asp.net c# develop...

asp.net - How to change Label text programmatically

Change Label text programmatically The Label class Represents a label control, which displays text on a Web page. The asp.net developers can use the Label control to display text in a set location on the web page. Unlike static text, asp.net c# developers can customize the displayed text through the Text property. The following asp.net c# tutorial code demonstrates how we can programmatically change a Label control’s text. Here we used the Label web server control’s Text property to change its contained text programmatically. The Label control Text property gets or sets the text content of the Label control. This property value is a String which is the text content of the control. The default value of this property is Empty. The asp.net developers have to use the Text property to specify or determine the text content of the Label control. The Label control’s Text property is commonly used to programmatically customize the text that is disp...

asp.net - How to use associated control id in Label

AssociatedControlID in Label Server Control The Label is an ASP.NET web server control that displays text on the web page. Label control’s AssociatedControlID property gets or sets the identifier for a server control that the Label control is associated with. The AssociatedControlID property value type is a String. This String represents the ID of server control in the web form. The default value of this property is an empty String which means the Label server control is not associated with any other server control. By using this property we can extend the functionality of the associated control. We can use the Label control as a caption for other control or we can set the tab index or hotkey for associated server control. We can set the Label AccessKey property to provide the hotkey for associated control. We also can use the Label Text property to set a caption for associated server control. The following ASP.NET C# example code...

RadioButton OnCheckedChanged event in asp.net

CheckedChanged event in RadioButton RadioButton is an asp.net web server control. radio buttons are grouped logically when they share the same value for the GroupName property. Users can select one radio button at a time within a radio button group. GroupName property specifies a grouping of radio buttons to create a mutually exclusive set of controls. RadioButton OnCheckedChanged method raises the CheckedChanged event of RadioButton control. This method allows us to write an event handler for the RadioButton CheckedChanged event. RadioButton CheckedChanged event occurs when the Checked property value changes between posts to the server. This event only works when we set the RadioButton AutoPostBack property value to true. By using this event we can determine the checked status of RadioButton immediately after the user change the selection of RadioButton. RadioButton Checked property gets or sets a value that indicates whether the RadioBut...

How to use ListBox SelectedIndexChanged event in asp.net c#

ListBox SelectedIndexChanged Event ListBox is an asp.net list web server control that contains a list of selectable items. More than one item is visible in ListBox control. ListBox SelectionMode property determines whether multiple items in the ListBox are selectable at a time. ListBox SelectedIndexChanged event occurs when the SelectedIndex property or the SelectedIndices collection has changed. ListBox SelectedIndex property gets or sets the zero-based index of the currently selected item. And SelectedIndices property gets a collection that contains the zero-based indexes of all currently selected items in ListBox. For multiple selections, the ListBox SelectedIndices property returns a collection containing the indexes of all selected items. ListBox SelectedIndexChanged event works when we set the ListBox AutoPostBack property value to True and write an event handler for the OnSelectedIndexChanged property. when a user changes the sele...

RadioButtonList SelectedIndexChanged event in asp.net c#

SelectedIndexChanged event in RadioButtonList RadioButtonList is an ASP.NET list web server control that provides a single selection radio button group. RadioButtonList can be populated statically or dynamically from a data source object. RadioButtonList contains an item collection that holds ListItem objects. Each ListItem object represents an item (radio button) in RadioButtonList control. RadioButtonList OnSelectedIndexChanged method raises the SelectedIndexChanged event. This method allows us to provide a custom handler for the SelectedIndexChanged event. RadioButtonList SelectedIndexChanged event occurs when the item selection changes between posts to the web server. This event works only when we set the RadioButtonList control's AutoPostBack property value to True. AutoPostBack property gets or sets a value indicating whether a postback to the server automatically occurs when the user changes the list selection. So when the us...

How to use RadioButtonList AutoPostBack in asp.net c#

AutoPostBack feature in RadioButtonList The following ASP.NET C# example code demonstrates to us how can we use the RadioButtonList AutoPostBack property/feature. RadioButtonList is an asp.net list web server control that renders a radio group on the web page. RadioButtonList provides a single selection/check radio group. Users can select an item from RadioButtonList at a time. We can get the user selection from a RadioButtonList after page submission to the web server. RadioButtonList control has a property named AutoPostBack which allows us to automatically submit the page to web server each time the RadioButtonList item selection is changed. AutoPostBack property accepts a Boolean value. If we set the AutoPostBack property value to true then each time we change the RadioButtonList item selection, it posts the web page to the server. If we set the AutoPostBack property value to false then it does not post the page to the server when we ch...

asp.net - Add an item to a RadioButtonList programmatically

Add list item to RadioButtonList programmatically RadioButtonList is an ASP.NET list web server control that allows us to render a single selection radio button group in the web browser. RadioButtonList control contains an item collection that holds all ListItem objects. We can populate a RadioButtonList control statically by declarative syntax. We also can populate a RadioButtonList control dynamically by data binding with a data source object. RadioButtonList server control has built-in properties and methods to customize it. We can change the default look and feel of a RadioButtonList control. Even we can programmatically add or remove items from its items collection at run time. Each ListItem object has three possible properties those are Text, Value, and Selected. We can create a ListItem object programmatically. We also can add this ListItem object to RadioButtonList control's Items collection programmatically. Items collection'...

How to add an item to BulletedList programmatically

Add an item to BulletedList programmatically BulletedList is an ASP.NET list web server control. ASP.NET developers use BulletedList server control to create a list of items that are formatted with bullets. The BulletedList Items property gets the collection of items in the BulletedList control. Items collection contains all ListItem objects. A ListItem object represents a single item in BulletedList control. ListItem object has three properties that are Text, Value, and Selected. Text property text is displayed in BulletedList control and Value property text is associated with ListItem and is hidden in the browser. The Selected property indicates whether ListItem is selected or not. We can add ListItem objects of BulletedList server control at design time. We also can populate BulletedList by data binding with data source control. Even we can add items to BulletedList control programmatically at run time. To add an item programmaticall...

CheckBoxList SelectedIndexChanged event in asp.net c#

CheckBoxList SelectedIndexChanged Event Asp.net CheckBoxList web server control provides a multi-selection checkbox group. this is a list server control. list server control contains an Items collection that holds all ListItem Objects. ListItem objects have three useful properties they are Text, Value, and Selected. CheckBoxList control's OnSelectedIndexChanged property raises the SelectedIndexChanged event. this property allows the developers to write a custom handler for the SelectedIndexChanged event. The SelectedIndexChanged event is raised when the selection from the CheckBoxList control changes between posts to the server. so when a user changes a selection from CheckBoxList control then the SelectedIndexChanged event is raised and the page automatically posts to the web server. for that happening developers need to set the CheckBoxList AutoPostBack property value to True. when someone changes the selection from CheckBoxList then th...

How to use AutoPostBack in asp.net c# CheckBoxList

AutoPostBack feature in CheckBoxList CheckBoxList is an ASP.NET web server control. This server control creates a multi-selection CheckBox group. CheckBoxList can be dynamically populated by binding the data source. CheckBoxList AutoPostBack property gets or sets a value indicating whether a postback to the server automatically occurs when the user changes the CheckBoxList selection. This property value type is a Boolean. If we set the property value to true then a postback automatically occurs when the user changes the CheckBoxList selection. And if we set this property value to false then automatic postback to the server will be disabled. The default value of this property is false. CheckBoxList SelectedIndexChanged event occurs when the selection of CheckBoxList changes between posts to the server. to work this event properly we need to set the CheckBoxList AutoPostBack property value to true. The following ASP.NET C# example co...

asp.net - How to find an item by value from a DropDownList

DropDownList FindByValue(String) Method DropDownList server control creates a single selection drop-down-list control. Asp.net developers can place ListItem objects between opening and closing tags of DropDownList control to specify list items. Each ListItem object represents a single item in DropDownList. Developers also can populate a DropDownList with items by using various data source controls such as SqlDataSource, LinqDataSource, ObjectDataSource, etc. ListItem represents a data item in DropDownList control. ListItem Text property gets or sets the text displayed in DropDownList and the Value property gets or sets the value associated with the ListItem. Value is hidden in the browser. We can find ListItem from a DropDownList Items collection programmatically by the specific ListItem value. DropDownList Items property gets the collection of items in DropDownList. The .net ListItemCollection class’s FindByValue() method searches a ListItem...

asp.net - How to find an item by text in a DropDownList

DropDownList.Items.FindByText(String) Method DropDownList represents a control that allows the user to select a single item from a drop-down list. The .NET developers can populate a DropDownList control by items using data bind with a data source control. They also can specify DropDownList items by placing ListItem objects between opening and closing DropDownList tags using declarative syntax. ListItem object has a Text property that gets or sets the text displayed in DropDownList. And have a Value property that is associated with the ListItem. Value property value is hidden in the web browser. We can find a DropDownList item by its Text property programmatically at run time. The .NET ListItemCollection class’s FindByText() method searches the item collection for a ListItem with a Text property that equals the specified text. This method is case-sensitive and culture-insensitive. The null is returned if this method does not find an item. ...

How to use DropDownList AutoPostBack in asp.net c#

DropDownList AutoPostBack Feature DropDownList control allows users to select an item from a single selection drop-down list. We can specify DropDownList items by placing ListItem elements between the opening and closing tags of the DropDownList control. The .NET developers can also populate DropDownList from a data source object such as SqlDataSource, ObjectDataSource, LinqDataSource, ArrayList, Array, etc. The DropDownList DataBind method binds the data source to the DropDownList control. Users can select an item from DropDownList and manually submit the form using submit button to send their selection to the server. This way we can get user selection by clicking a submit button. But ASP.NET DropDownList is a more user-friendly server control. It has a property name AutoPostBack. AutoPostBack property works with the SelectedIndexChanged event. AutoPostBack property gets or sets a value that indicates whether a postback to the server au...

How to find ListBox item by text in asp.net c#

Find ListBox Item By Text ListBox is an ASP.NET list web server control. Developers can use the ListBox control to create a single or multi-item selection list control. We can set single selection or multi-selection mode using the ListBox SelectionMode property. ListBox Items property contains all ListItem objects. ListBox can populate with items from a data source control. So a ListBox can exists many items. Each ListItem object has a Text and a Value property. Text property holds the text to display in ListBox and Value property text is associated with the ListItem object and is hidden in the web browser. The .NET C# developers can find/search a ListItem object in ListBox using the ListItem Text property value. To find an item using its Text we need to use the Items FindByText(String) method. Items FindByText() method finds an item from ListBox using its Text property string. The following C# example source code demonstrates to us how ...

How to data bind ListBox programmatically in asp.net c#

Data bind ListBox programmatically ListBox is an ASP.NET list web server control. ListBox control's items collection contains ListItem objects. We can populate a ListBox with items by declarative syntax. We can place the ListItem element between the opening and closing tags of the ListBox control to display it in the browser. ListBox server control supports data binding. To bind the ListBox control to a data source control, developers need to first create a data source such as a DataSourceControl object. DataSourceControl serves as the base class for controls that represent data sources to data-bound controls. The DataSourceControl object contains the items to display in the ListBox. Next developers can call the ListBox DataBind method to bind the data source to the ListBox. ListBox DataTextFiled and DataValueField properties specify which field in the data source to bind the Text and Value properties. After data binding, ListBox control wil...

ColdFusion: How to invoke a method of a component

Introduction In Adobe ColdFusion, one of the most powerful features is the ability to create reusable code components known as ColdFusion Components (CFCs). These components allow developers to encapsulate functionality into manageable and modular code blocks. One common task in ColdFusion development is invoking methods from these components in order to execute specific functionality or retrieve data. ColdFusion provides the <cfinvoke> tag to facilitate this process, allowing developers to easily call methods from a component (CFC). Additionally, the <cfinvokeargument> tag is used to pass arguments to the method being invoked. In this tutorial, we'll explore how to invoke a method from a CFC using the <cfinvoke> and <cfinvokeargument> tags, demonstrated by a simple example that retrieves table data from a database. Component Overview The tutorial consists of two files: cfinvokeargument.cfm and TableData.cfc . The first file is a ColdFusion page that de...

How to invoke a method of a component in ColdFusion

Introduction This tutorial demonstrates how to invoke a method of a ColdFusion component (CFC) using the <cfinvoke> tag. ColdFusion components are reusable modules that encapsulate data and functionality, and they are an essential part of ColdFusion's object-oriented programming approach. The example provided shows how to interact with a component to retrieve data from a database table dynamically. By the end of this tutorial, you will understand how to define a CFC, create methods within the component, and call those methods using <cfinvoke> in ColdFusion. In this example, we have two files: cfcomponent.cfm , which acts as the main interface for invoking the component, and DataViewer.cfc , which contains the logic for retrieving data from a database. Let’s break down the code step by step to understand the roles of these files and how they interact with each other. Defining the Component in ColdFusion The core of this example is the DataViewer.cfc file, which define...