How to get dynamic headers & Footers
-
hi all, Am making a web application in asp.net and i have a problem...i.e How can i make dynmic headers and footers to my application using placeholder controls. I have got one example for this in this site itself from Mr.ajay,but its in c#. What i exactly need is how can i get the same in VB.Net. Plz....help me... waiting for all the early replys....... :^) Live Life King Size Asif
-
hi all, Am making a web application in asp.net and i have a problem...i.e How can i make dynmic headers and footers to my application using placeholder controls. I have got one example for this in this site itself from Mr.ajay,but its in c#. What i exactly need is how can i get the same in VB.Net. Plz....help me... waiting for all the early replys....... :^) Live Life King Size Asif
You can place contentplaceholders in your master but you will still need to use user controls. I used one for left and right sides of the page. Like this (in VB.Net).
Dim UserCntrl As SideMenu UserCntrl = CType(LoadControl("UserControls/SideMenu.ascx"), SideMenu) If CStr(Session("MenuPos")) = "Left" Then Me.ContentPlaceHolderLeft.Controls.Add(UserCntrl) Else Me.ContentPlaceHolderRight.Controls.Add(UserCntrl) End If
You can also access a placeholder from a content page. like this.Dim page As Page page = CType(Me.Parent.Page, Page) Dim pleft As ContentPlaceHolder pleft = CType(page.Master.FindControl("ContentPlaceHolderLeft"), ContentPlaceHolder) pleft.Controls.Clear() Dim pright As ContentPlaceHolder pright = CType(page.Master.FindControl("ContentPlaceHolderRight"), ContentPlaceHolder) pright.Controls.Clear() Dim UserCntrl As SideMenu UserCntrl = CType(LoadControl("SideMenu.ascx"), SideMenu) If Me.LinkButton3.Text = "Move Right" Then Web.HttpContext.Current.Session("MenuPos") = "Right" pright.Controls.Add(UserCntrl) End If If Me.LinkButton3.Text = "Move Left" Then Web.HttpContext.Current.Session("MenuPos") = "Left" pleft.Controls.Add(UserCntrl) End If
"People who never make mistakes, never do anything." My Blog -
You can place contentplaceholders in your master but you will still need to use user controls. I used one for left and right sides of the page. Like this (in VB.Net).
Dim UserCntrl As SideMenu UserCntrl = CType(LoadControl("UserControls/SideMenu.ascx"), SideMenu) If CStr(Session("MenuPos")) = "Left" Then Me.ContentPlaceHolderLeft.Controls.Add(UserCntrl) Else Me.ContentPlaceHolderRight.Controls.Add(UserCntrl) End If
You can also access a placeholder from a content page. like this.Dim page As Page page = CType(Me.Parent.Page, Page) Dim pleft As ContentPlaceHolder pleft = CType(page.Master.FindControl("ContentPlaceHolderLeft"), ContentPlaceHolder) pleft.Controls.Clear() Dim pright As ContentPlaceHolder pright = CType(page.Master.FindControl("ContentPlaceHolderRight"), ContentPlaceHolder) pright.Controls.Clear() Dim UserCntrl As SideMenu UserCntrl = CType(LoadControl("SideMenu.ascx"), SideMenu) If Me.LinkButton3.Text = "Move Right" Then Web.HttpContext.Current.Session("MenuPos") = "Right" pright.Controls.Add(UserCntrl) End If If Me.LinkButton3.Text = "Move Left" Then Web.HttpContext.Current.Session("MenuPos") = "Left" pleft.Controls.Add(UserCntrl) End If
"People who never make mistakes, never do anything." My Blog