Showing posts with label Master Page. Show all posts
Showing posts with label Master Page. Show all posts

Monday, August 31, 2009

set meta tags to master page from Child Page

Meta tag ,title, keywords ,Description and all are very assential on each page , if your using asp.net with Master page then also its possible some people think that how it can be? master page means one page and it get call on each child page creation.but you can also add the keyword , title and all with each pertucular page if you'r using master page then also.

Below are the Steps you need to follow

1-

Create oen Content place holder on your master page with in HEAD section


<head id="Head_Demo" runat="server">
<asp:ContentPlaceHolder runat="server" id="Contentplace_Demo"> </asp:ContentPlaceHolder>
</head >


2 -

on Your Child page put this code :

<asp:Content runat="server" ContentPlaceHolderID="ContentHeaders" ID="Content_Demo" >
<META name="keywords" content="<%=pgKeywords%>">
<TITLE><%=pgTitle%></TITLE>
<META name="description" content="<%=pgDescription%>">
</asp:Content>


3 -

on content page's(Child page) open CodeBehind and Declare this :
Declare variables as below in the global declaration section

Protected pgKeywords As String = ""
Protected pgTitle As String = ""
Protected pgDescription As String = ""


4-
Now set the New title, Desc and all as per the your req. copy that code on page_load Event

pgKeywords = "keywords Content Goes here "
pgTitle = "title Content Goes here"
pgDescription = "Description Content Goes here"

or you can also refer this set mata tags

that's it
hope it will helps you

Thursday, August 13, 2009

Handle Master page Click Event on Content Page

In ASP.net2.5 there a new concept knowns as Master Page , with the help of that you can
customize you'r repeteative work. Create a one Master page and use that page on all the other pages. Its really very good tech to crear your coding and clear your logic also.

now sometime we have a LinkButton define on Master page which can be work as a "Link to the Customer information " and this can be change depend on customer role. and that LinkButton action we want in the Contenet page.

Supoose we have LinkButton call "linkFromMasterPage" on Master Page. Here is small code which can helps you to do same .

C#--

Public LinkButton linkFromMasterPage(){

Get {

Return linkFromMasterPage;

}

}


Now next Process is reference the Master Page as a casted object in the Content page.
here CusMasterPg is a Class of Maste Page.


CusMasterPg cm = ((CusMasterPg) (Master));


Now you can easily access the all the methods, public properties of Master page class.
so next stpe is handle the button Event on your content page


protected void Page_Load(object sender, EventArgs e)
{
If (!(IsNothing(cm))) {

cm.linkFromMasterPage.Click += New EventHandler(linkFromMasterPage_Click);

}
}


next thing is define actual method handle on your page.


Protected void linkFromMasterPage_Click(Object sender, System.EventArgs e){

// write Perform Business Logic Here
}


thats all , you can do same thing for User Controls also for Handle Master page Click Event on Content Page.