homepage Welcome to WebmasterWorld Guest from 184.73.72.163
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
how to add code in masterpage tag
hal12b




msg:4301393
 5:36 pm on Apr 20, 2011 (gmt 0)

I was wondering how I can modify this

<%@ Page Title="" Language="VB" MasterPageFile="~/Products/PersonalInsurance/New/MasterPageSubPageTABLES.master" AutoEventWireup="false" CodeFile="auto-insurance.aspx.vb" Inherits="Products_PersonalInsurance_New_Default" %>

to fill in a variable in the title area. I have pages that are database driven and want the title tag to change for each page. In the content area I just have this --> <%=strPageContent%>

Obviously, this isn't working -->


<%@ Page Title="<%=strPagetitle%>" Language="VB" MasterPageFile="~/Products/PersonalInsurance/New/MasterPageSubPageTABLES.master" AutoEventWireup="false" CodeFile="auto-insurance.aspx.vb" Inherits="Products_PersonalInsurance_New_Default" %>

First person to answer get a virtual high five.

 

wyweb




msg:4301394
 5:38 pm on Apr 20, 2011 (gmt 0)

First person to answer get a virtual high five

I'd take one of those right now.

I can't answer your question though.

High five me anyway.

hal12b




msg:4301401
 5:45 pm on Apr 20, 2011 (gmt 0)

ha ha.
OK, here's a HIGH FIVE to you.

Maybe I should have said first person with a working solution gets the virtual high five! ha ha

mattglet




msg:4301511
 9:34 pm on Apr 20, 2011 (gmt 0)

Here's an oldie but a goodie:

[4guysfromrolla.com...]

marcel




msg:4301736
 7:26 am on Apr 21, 2011 (gmt 0)

I assume you're getting the values in Page_Load for this example:


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' Get values from DB
Page.Title = strPagetitle
End Sub

hal12b




msg:4301920
 3:27 pm on Apr 21, 2011 (gmt 0)

Awesome. It works.. Any idea how I could do this for meta descriptions or key phrases also?

marcel




msg:4302065
 6:51 pm on Apr 21, 2011 (gmt 0)

are you using .NET 4.0? then it is as easy as this:

Page.MetaKeywords = "These, are my, meta, keywords"
Page.MetaDescription = "This is my meta description."

hal12b




msg:4303755
 7:01 pm on Apr 25, 2011 (gmt 0)

Marcel,
Unfortunately not. They are not working. What else can you suggest? HAL

marcel




msg:4304007
 9:21 am on Apr 26, 2011 (gmt 0)

I haven't tested this, but you should get the general idea:

(Add the runat="server" attribute to your the head tag)


Dim hd As HtmlHead = CType(Page.Master.FindControl("Head"), HtmlHead)
Dim mt As New HtmlMeta
mt.Attributes.Add("name", "description")
mt.Attributes.Add("content", "Place your description here")
hd.Controls.Add(mt)

mt = New HtmlMeta
mt.Attributes.Add("name", "keywords")
mt.Attributes.Add("content", "place, your, keywords, here")
hd.Controls.Add(mt)

hal12b




msg:4324235
 7:46 pm on Jun 9, 2011 (gmt 0)

Sorry for not getting back in a while. I had to put this project on hold, but I am back now. We have ASP.NET version 2.0.50727.4211

Is there any harm in upgrading to 4.0?

Ocean10000




msg:4325117
 12:22 am on Jun 12, 2011 (gmt 0)

Shouldn't be that much of a problem from what I am reading.

hal12b




msg:4325634
 8:12 pm on Jun 13, 2011 (gmt 0)

Thanks. I will look at doing this shortly.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved