Welcome to WebmasterWorld Guest from 50.17.87.126

Forum Moderators: ocean10000

Message Too Old, No Replies

how to add code in masterpage tag

     

hal12b

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

5+ Year Member



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

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

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

5+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



Here's an oldie but a goodie:

[4guysfromrolla.com...]

marcel

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

WebmasterWorld Senior Member 10+ Year Member



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

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

5+ Year Member



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

marcel

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

WebmasterWorld Senior Member 10+ Year Member



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

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

5+ Year Member



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

marcel

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

WebmasterWorld Senior Member 10+ Year Member



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

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

5+ Year Member



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

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

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



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

hal12b

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

5+ Year Member



Thanks. I will look at doing this shortly.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month