Refresh only content place holder without refreshing master page
- Create menu.ascx and edit as
<div class="menu">
<ul>
<li><a href="Default.aspx?menu=Home">Home</a></li>
<li><a href="Default.aspx?menu=Admin">Admin</a></li>
<li><a href="Default.aspx?menu=About">About</a></li>
</ul>
</div>
- Create
- Home.ascx
- Admin.ascx
- About.ascx
- change masterpage.master.cs file
protected void Page_Load(object sender, EventArgs e)
{
LoadMenu();
}
private void LoadMenu()
{
string menu = Request.QueryString["menu"];
Control c;
switch (menu)
{
case "Home":
c = Page.LoadControl(Request.ApplicationPath + "/UserControlMenu/LeftMenuHome.ascx");
break;
case "Admin":
c = Page.LoadControl(Request.ApplicationPath + "/UserControlMenu/LeftMenuAdmin.ascx");
break;
case "About":
c = Page.LoadControl(Request.ApplicationPath + "/UserControlMenu/LeftMenuAbout.ascx");
break;
default:
c = Page.LoadControl(Request.ApplicationPath + "/UserControlMenu/LeftMenuHome.ascx");
break;
}
leftMenuContentPlaceHolder.Controls.Add(c);
}
No comments:
Post a Comment