Showing posts with label ASP.NET AJAX 3.5 Example. Show all posts
Showing posts with label ASP.NET AJAX 3.5 Example. Show all posts

Wednesday, March 25, 2009

ASP.NET AJAX and Calendar Control

Normally when we use calendar control in asp.net we see that calendar control occupies lot of space and selecting a date will cause a post back.

To avoid that problem we can use AJAX to select a date from calendar control with out any page post back and hiding the calendar control will save lot of space.

Now lets create a web application and add a script manager and a update panel control, now under update panel add text box, button and a calendar control as shown the below screen shot and make calendar control visible property to false

image

Now lets write logic in .cs file for that double click on Button and add following code

Calendar1.Visible = true;

and double click on calendar control and add following code

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
    TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
    Calendar1.Visible = false;
}

 

Now we are ready with our code, lets run build and test.

 

image

 

Hope this helps.

 

Friday, February 27, 2009

ASP.NET AJAX 3.5 Example

`In this example I am Using AJAX to show how you can display data using AJAX.

This will work very fast and you will see there is not page reload is occurring

Create a Web Application and modify Default.aspx html content
I am adding Script manager control and a Update Panel control, Under Update panel control add 2 labels and 2 dropdownlist control and gridview like below

Once Modify Default.aspx, open Default.aspx.cs and modify the Page_Load and add following code.

Now we will add code to fetch the Orders by particular Employee, for that we need write code in DropDownList1_SelectedIndexChanged event, please add following code

Now we will fetch the order details of selected order number for that we need to add the following code in DropDownList2_SelectedIndexChanged event

Now we are ready with over code, just build, run and test

Hope this help you.