Solved

Setting HtmlMeta from outside class

Posted on 2009-04-09
3
293 Views
Last Modified: 2012-05-06
I want to dynamically set the page Meta Tags based on certain criteria .. I'm using the following function..

The code works fine if placed in the same page, however, since what I want to do has more to do, I thought I want to place this code in a separate class and call it when I need it .. the problem is getting is issue:


'MyClassName' does not contain a definition for 'Header' and no extension method 'Header' accepting a first argument .... etc..

any idea of how can I cast or pass the value..

Thank you

public void setMeta(string tagName, string tagContent)

    {
 

        HtmlMeta meta_desc = new HtmlMeta();

        meta_desc.HttpEquiv = tagName;

        meta_desc.Content = tagContent;

        this.Header.Controls.Add(meta_desc);
 

    }

Open in new window

0
Comment
Question by:NevinsLtd
  • 2
3 Comments
 
LVL 37

Expert Comment

by:samtran0331
ID: 24111613
your "MyClassName" class has to inherit from System.Web.UI.Page
and then your pages should inherit from MyClassName

the technique is called "base pages"
0
 
LVL 37

Accepted Solution

by:
samtran0331 earned 500 total points
ID: 24111636
example:
http://www.4guysfromrolla.com/articles/041305-1.aspx

you can also google "asp.net base page" for tons more...ultimately...it lets your aspx pages have one place for shared code
0
 

Author Closing Comment

by:NevinsLtd
ID: 31568755
Thanks for the hints
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now