0% found this document useful (0 votes)
54 views

Md. Arafat Hossain Khan (Sagar)

This document provides guidelines for implementing AJAX functionality in an ASP.NET professional project. It involves creating stored procedures to retrieve selected and non-selected menu items, adding a ScriptManager control, updating an aspx page to include an UpdatePanel, and modifying the aspx.cs codebehind to bind data based on a dropdown selection. Partial page updates are enabled through AJAX to refresh a gridview without reloading the whole page.

Uploaded by

bluewhiteas4486
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Md. Arafat Hossain Khan (Sagar)

This document provides guidelines for implementing AJAX functionality in an ASP.NET professional project. It involves creating stored procedures to retrieve selected and non-selected menu items, adding a ScriptManager control, updating an aspx page to include an UpdatePanel, and modifying the aspx.cs codebehind to bind data based on a dropdown selection. Partial page updates are enabled through AJAX to refresh a gridview without reloading the whole page.

Uploaded by

bluewhiteas4486
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Guideline for ASP.

NET Professional Project

Lecture_04 (AJAX)

Created by
Md. Arafat Hossain Khan (Sagar)
Lecturer
Department of
Electronics and Telecommunication Engineering
The People’s University of Bangladesh
Wednesday, August 28, 2010
1. Open SQL Server Management Studio

2. Rename get_menu_items as get_selected_menu_items


3. Create a new Stored Procedure named get_not_selected_menu_items with the following query

SELECT * FROM TopMenu WHERE MenuItemSelected != 1;


4. In TopMenu.ascx.cs file hange the line

SqlCommand cmd = new SqlCommand("dbo.get_menu_items", connection);

to
SqlCommand cmd = new SqlCommand("dbo.get_selected_menu_items", connection);

5. Now in the master page file Site.master add a ScriptManager just after the form tag

<form id="form1" runat="server">


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

6. Now change open the DefaultAdmin.aspx page and change the content to

<%@ Page Language="C#" MasterPageFile="~/MasterPages/Site.master" AutoEventWireup="true"


CodeFile="DefaultAdmin.aspx.cs" Inherits="Pages_Admin_DefaultAdmin" Title="Untitled
Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphContent" runat="Server">


<asp:UpdatePanel ID="uplgvTopMenu" runat="server">
<ContentTemplate>
<asp:UpdateProgress ID="uprgvTopMenu" runat="server">
<ProgressTemplate>
<img src="../../Images/updateprogress.gif" alt="Updating..." />
</ProgressTemplate>
</asp:UpdateProgress>
<asp:GridView ID="gvTopMenu" runat="server" align="left">
</asp:GridView>
<asp:Label ID="Label1" runat="server"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlgvTopMenuUpdate"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<asp:DropDownList ID="ddlgvTopMenuUpdate" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="ddlgvTopMenuUpdate_SelectedIndexChanged">
<asp:ListItem Selected="True" Value="All">
All Menu Items
</asp:ListItem>
<asp:ListItem Value="True">
Menu Items Selected
</asp:ListItem>
<asp:ListItem Value="False">
Menu Items Not Selected
</asp:ListItem>
</asp:DropDownList>
</asp:Content>
7. Now change open the DefaultAdmin.aspx.cs page and change the content to

public partial class Pages_Admin_DefaultAdmin : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{
gvTopMenu.DataSource = Common.SQLServerConnection("dbo.get_all_menu_items");
gvTopMenu.DataBind();
}
protected void ddlgvTopMenuUpdate_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlgvTopMenuUpdate.SelectedItem.Value == "All")
{
gvTopMenu.DataSource = Common.SQLServerConnection("dbo.get_all_menu_items");
gvTopMenu.DataBind();
System.Threading.Thread.Sleep(3000);
}
else if (ddlgvTopMenuUpdate.SelectedItem.Value == "True")
{
gvTopMenu.DataSource =
Common.SQLServerConnection("dbo.get_selected_menu_items");
gvTopMenu.DataBind();
System.Threading.Thread.Sleep(3000);
}
else if (ddlgvTopMenuUpdate.SelectedItem.Value == "False")
{
gvTopMenu.DataSource =
Common.SQLServerConnection("dbo.get_not_selected_menu_items");
gvTopMenu.DataBind();
System.Threading.Thread.Sleep(3000);
}
}
}

8. Now download a gif image to have update progress view. You can download from-
http://www.aspneti.com/images/updateprogress.gif
9. Now add this image to the Images folder-
10. And now run your application
11. You should get the partial page update feature implemented on your site when you will change the item
from the drop down list.

You might also like