Posts

Showing posts from December, 2013

How to use Asp.net calendar control

Image
Any time you want your users of the application, to provide a date, it is better to provide a calendar control from which they can select the date. In this session we will see how to do it.  Drag and drop a TextBox, ImageButton and a Calendar control on the webform. Create an Image folder and add the following Calendar.png to the Images folder.   Set the ImageUrl property of the image button to Calendar.png ImageUrl="~/Images/Calendar.png" HTML of the ASPX page <asp:TextBox ID="TextBox1" runat="server" Width="115px"></asp:TextBox> <asp:ImageButton ID="ImageButton1" runat="server"      ImageUrl="~/Images/Calendar.png" onclick="ImageButton1_Click" /> <asp:Calendar ID="Calendar1" runat="server" ondayrender="Calendar1_DayRender"      onselectionchanged="Calendar1_SelectionChanged"></asp:Calendar>   Code-Behind page code protected void  Pag

Fileupload control in asp.net

FileUpload control is a combination of a text box and a browse button that enable users to select a file to upload to the server. Create an asp.net web application project. Drag and drop the FileUpload control on the webform.   The fileUpload control only allows the user to select the file.  To upload the seleceted file, drag and drop a button control. Change the ID of the button to btnUpload and the Text to Upload File. Also drag and drop a label control, and change the ID of the label to lblMessage. At this stage the HTML of the webform should be as shown below. <asp:FileUpload ID="FileUpload1" runat="server" /> &nbsp; <asp:Button ID="btnUpload" runat="server" Text="Upload File"      onclick="btnUpload_Click" /> <br /> <asp:Label ID="lblMessage" Font-Bold="true" runat="server"> </asp:Label>   Right click on the web application project and add a folder with na

How to use ASP.NET RadioButtonList Control

Image
In ASP.NET there are several list controls, like 1.  DropDownList 2.  CheckBoxList 3.  BulletedList 4.  ListBox 5.  RadioButtonList In this video we will learn about asp.net RadioButtonList control. Just like every other list control 1.  RadioButtonList is also a collection of ListItem objects. 2.  Items can be added to the RadioButtonList in the HTML source or in the code behind file 3.  RadioButtonList like any other list control supports databinding. For example, RadioButtonList can be bound to a database table or an xml file   CheckBoxList is generally used , when you want to present the user with multiple choices, from which you want him to select one or more options. Where as if you want the user  to select only one option , then a RadioButtonList control can be used, i.e RadioButtonList is commonly used to present mutually exclusive choices. Create an asp.net web application. Copy and paste the following HTML <asp:RadioButtonList ID="ColorRadioButtonList" runat=&q

ASP.NET CheckBoxList and ListBox real time example

Copy and Paste the following HTML on the ASPX page <asp:CheckBoxList ID="CheckBoxList1" runat="server"      RepeatDirection="Horizontal" AutoPostBack="True"      onselectedindexchanged="CheckBoxList1_SelectedIndexChanged">     <asp:ListItem Text="Diploma" Value="1"></asp:ListItem>     <asp:ListItem Text="Graduate" Value="2"></asp:ListItem>     <asp:ListItem Text="Post Graduate" Value="3"></asp:ListItem>     <asp:ListItem Text="Doctrate" Value="4"></asp:ListItem> </asp:CheckBoxList> <br /> <asp:ListBox ID="ListBox1" runat="server" Height="78px" Width="127px"> </asp:ListBox> <br /><br /> <asp:Label ID="lblMessage" runat="server" Font-Bold="true"></asp:Label>   Copy and Paste the following

How to use Asp.net ListBox control

Image
Just like  DropDownList  and CheckBoxList ,  ListBox  control is also a collection of ListItem objects. Working with ListBox control is very similar to DropDownList and CheckBoxList. Adding items and binding to a datasource is exactly similar. In this part of the video, let's discuss about the properties that are specific to the ListBox control.  Properties Rows :  The number of visible rows in the Listbox. A scrollbar is automatically generated, if the total number of item are greater than the number of visible rows in the listbox. SelectionMode :  SelectionMode can be Single or Multimple. By default, this property value is Single, meaning when the listbox renders, the user can select only one item from the listbox. Set this property to Multimple, to enable multiple item selections. To select, multiple items from the listbox, hold-down the CTRL key, while the listitem's are selected. Please note that, it is not possible to set the Selected property of more than one ListItem