.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

how to put head tag in child page of master page

Posted By: susant     Posted Date: February 19, 2009    Points:2   Category :ASP.Net
Hi all we are working one web-site with masterpage..
in masterpage <head> tag is there...
i am adding some new page link to the masterpage..
so in my child page there is no <head> so how can i put <head>tag so that i can add the javascript for specific masterpage..


Author: Amit Mehra             
Posted Date: February 19, 2009     Points: 5   

try likt this in your child page to add meta tag programatically.
in your page load event.

HtmlMeta meta= new HtmlMeta();
meta.Name = "keywords";
meta.Content = content;

Please "Mark As Answer " if this post help you.
Author: susant             
Posted Date: February 19, 2009     Points: 5   

Hi Amit

The code u send is it applicable for child page to add java script in <head> tag..??

I think something wrong.. i need to add <head> section so that i can add some javascript for my specific child page..


Author: Amit Mehra             
Posted Date: February 19, 2009     Points: 5   

Hi Susant,

No its C# code and HtmlMeta calss is available under System.Web.UI.HTMLControls.

Similarly you can use

This.Title = "MyTitle" ;// to set title tag dynamically.

Please "Mark As Answer " if this post help you.
Author: shahin             
Posted Date: February 24, 2009     Points: 5   

hi susant

u can use page.title property......
before that u hav to set child page title property individually ....
hope i understand what u ask....and may be it is useful to u....

Author: Sanjay Kumar             
Posted Date: April 17, 2009     Points: 5   

If you are using MasterPage add the child pages as content page then u don't need to have <Head> tag to write JavaScript. As I do like

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script type="text/jscript">
var TotalChkBx;
var Counter;

window.onload = function()
//Get total no. of CheckBoxes in side the GridView.
TotalChkBx = parseInt('<%= this.GridView1.Rows.Count %>');

//Get total no. of checked CheckBoxes in side the GridView.
Counter = 0;

Hope I have uderstood ur requirement...

If you want the Page Header caption or banner for each content page appear on the Master Page then
Step1 :- Put a label (Label1) on MasterPage's banner area or table or div whatever...
step2 :- On the content page's aspx.cs at page load event write the following code:
protected void Page_Load(object sender, EventArgs e)
Label HeaderLabel = (Label)Master.FindControl("Label1");
HeaderLabel.Text = "Bulk User Registration Form";

Hope I am near to ur requirement as u didn't mention exactly what u want.

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend