473,385 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how do I get a page's meta tag contents?

PJ6
Can't find anywhere in the docs that mentions a way to programmatically get
a page's meta tag collection. Reflection finds nothing in attributes. Can't
find anything in a page instance, either. Are they not accessible?

Paul
Nov 19 '05 #1
3 2443
Joe
this is how i did it

first make class that inherits from page
---------------------------------------------
using System.Text;
using System.Web.UI;
using System.IO;

namespace WebPageBase
{
public class PageBase : System.Web.UI.Page
{

protected System.Web.UI.HtmlControls.HtmlGenericControl alsideKeywords;
public string alsideKey
{
get
{
return alsideKeywords.Attributes["content"].ToString();
}
set
{
alsideKeywords.Attributes["content"] = value;
}
}
then make your meta tags "runat=server"
-------------------------------------------------
<meta name="keywords" id="alsideKeywords" content="Windows Siding"
runat="server"/>

make sure your page inherits from the new class and access like this
-------------------------------------------------------------------------------

// dr is a datareader
//sets keywords
if(dr["keywords"] != DBNull.Value)
((WebPageBase.PageBase)Page).alsideKey = dr["keywords"].ToString();
else ((WebPageBase.PageBase)Page).alsideKey = "Alside - Windows and Siding";

HTH.......

Joe

"PJ6" wrote:
Can't find anywhere in the docs that mentions a way to programmatically get
a page's meta tag collection. Reflection finds nothing in attributes. Can't
find anything in a page instance, either. Are they not accessible?

Paul

Nov 19 '05 #2
there isn't one. unless your meta tags have a runat=server, they are just
generic html defined in a generic html control. all the html between
servercontrols is loaded in a single generic control and added to the
controls collection.

-- bruce (sqlwork.com)
"PJ6" <no****@nowhere.net> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
Can't find anywhere in the docs that mentions a way to programmatically
get a page's meta tag collection. Reflection finds nothing in attributes.
Can't find anything in a page instance, either. Are they not accessible?

Paul

Nov 19 '05 #3
PJ6
Well that works but I think it's generally poor design to have any metadata
collection require instantiation. I know there is some hocus-pocus going on
in the background to build the temporary assemblies that support ASP.NET,
but I don't think it could have been too much of a stretch to have included
the meta tags as attributes in the created types that populate the ASP
namespace.

I was considering helping a client maintain their own metadata more easily
by just letting them alter meta tags on the pages themselves. But having to
instantiate each class to do something like collect metadata for all pages
just isn't going to fly. I'll have to use real attributes on the underlying
vb classes, and alteration of metadata will require editing the code itself
and a recompile, or perhaps I'll store it in SQL Server using a loose data
model if I don't consider that overkill for this particular project.

Paul

"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
this is how i did it

first make class that inherits from page
---------------------------------------------
using System.Text;
using System.Web.UI;
using System.IO;

namespace WebPageBase
{
public class PageBase : System.Web.UI.Page
{

protected System.Web.UI.HtmlControls.HtmlGenericControl alsideKeywords;
public string alsideKey
{
get
{
return alsideKeywords.Attributes["content"].ToString();
}
set
{
alsideKeywords.Attributes["content"] = value;
}
}
then make your meta tags "runat=server"
-------------------------------------------------
<meta name="keywords" id="alsideKeywords" content="Windows Siding"
runat="server"/>

make sure your page inherits from the new class and access like this
-------------------------------------------------------------------------------

// dr is a datareader
//sets keywords
if(dr["keywords"] != DBNull.Value)
((WebPageBase.PageBase)Page).alsideKey = dr["keywords"].ToString();
else ((WebPageBase.PageBase)Page).alsideKey = "Alside - Windows and
Siding";

HTH.......

Joe

"PJ6" wrote:
Can't find anywhere in the docs that mentions a way to programmatically
get
a page's meta tag collection. Reflection finds nothing in attributes.
Can't
find anything in a page instance, either. Are they not accessible?

Paul

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Magdelin | last post by:
Hi, I have a BasePage class from which all other ASPX pages of the project is inherited. The BasePage class implements Page_Load event handler. All child pages have its AutoEventWireUp property...
7
by: Brian Henry | last post by:
Hi, I have a data grid that has the following properties EnableViewState = false AllowPaging = true AllowSorting = true AllowCustomPaging = false now, when the page switches I want to get...
2
by: Goober | last post by:
I have the following default.aspx page that works properly. However, what I want to do is to link the graphics within it (that are hard coded now in the default web page) to our corporate...
12
by: Logan | last post by:
Hi, I am not a very experienced asp.net developer, but have a fair idea on how it works & better idea on vb.net. My requirement is to place an asp.net page on a website - which currently has...
0
by: Andrew Westgarth | last post by:
Hi all, i'm struggling with a page idea I have. I need to write a page with an A to Z list of available schools in the area. I only want to display the letters in the A to Z which have school...
6
by: Dariusz Tomon | last post by:
Hi How can I get url of page so taht I can pass it to string varaible. I have got several urls in my IIS under one folder. I want to have one default.aspx where code under it recognize which...
5
by: murrayatuptowngallery | last post by:
I'm caught in a classic finger-pointing situation. My hosting company's server appears to be automatically inserting JS tags into a JS-free html page that has an image inked to a 2nd page with...
7
by: dongdong | last post by:
using web browser can get page's content formally, but when use urllib2.open("http://tech.163.com/2004w11/12732/2004w11_1100059465339.html").read() the result is <html><head><META...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.