views:

116

answers:

2

I have the following code:

List<HtmlMeta> metas = new List<HtmlMeta>();
foreach (Control c in this.Page.Header.Controls)
    if (c.GetType() == typeof(HtmlMeta))
    {
        HtmlMeta meta = (HtmlMeta)c;
        if (meta.Name == "CategoryID")
            strMeta = meta.Content;
    }

I created this custom meta tag:

<meta id ="CategoryID" name="CategoryID" content="35" />

I step through the code and break at if (meta.Name == "CategoryID")

It gets to the meta tag before this then shows meta.name ="" then exits loop. It never sees my custom meta tag.

The tag before this one is: <meta name="verify-v1" content="AtroutoUUTAiOHzlmZOap4a5YdzOByK5v9bzwpzPy60=" />

Now you may ask why would I do this. I am using DotNetNuke CMS, I need a way for the end user to put in a parameter needed for a query in the backend code. I cannot seem to put anything in the url , like a querystring off the link to get to the page, so I tried a meta tag, as they can add this in the settings of the page(tab) in dnn.

I have tried leaving out id in the tag and just name, but same issue.

I am looking forr a simple and non resource intense solution.

Any insight to this or workaround in dnn or ASP.net would be great.

Thanks in advance.

+1  A: 

How are you adding the meta controls to the page? How is the "verify-v1" tag actually added to the page?

I ask because normal HTML controls don't appear in the Controls collection, unless they have runat="server" in their declaration, or they are added to the page dynamically through your .NET code.

If your mark-up looks something like this:

<meta name="CategoryID" value="<%=categoryId%>" />

Then you wouldn't be able to find the meta control the way you are trying to.

You should leave out the ID of the tag, as that's not supported by the spec.

Zhaph - Ben Duguid
I add the meta to the page using the settings of the tab in DotNetNuke. My markup is static. If I leave out ID same issue.
James Campbell
A: 

My solution does work, it is the process of how the page is rendered in DotNetNuke.

James Campbell