Monday, January 24, 2011

Add Date picker to ASP page from AjaxControlToolkit

Atfirst make a folder named i.e "Library" in your project folder. Then go to the References of Solution Explorer.

And Right Click-->Add References-->Select Browse--> Select the file from the location--> Add it.
Then add the text box, the target of the Selected Date. And also take a button or image by clicking which we will get our Calender.

The add the following code after the code of Button in the source view of the Form.

asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtBoxName" PopupButtonID="btnName"
Format="dd-MMM-yyyy"/>

Here the Format is used to define the format of your desired date to view.
After that, go to the next line of the FORM tag in your page. If you are using the Master Page as the part of your design. You will have to go to the FORM tag of your master page.Now you will have to add ScriptManager. For doing so, you will add the following line:


asp:ScriptManager ID="ScriptManager1" runat="server"/>


That's enough. You will get the Calender to pick the date.


IN this topic we have used code, but you can get this tool automatically from the Html portion of Toolbox menu. For doing so, you will have to Right Click on the lower part of Toolbox and then add the AjaxControlTool.dll from your made Library Folder. Then you will get these items from the Toolbox menu.


Click to get AjaxControlTool

No comments: