how to embed code-behind variable into html <meta> tag

G

Guest

Is it possible to use the <% %> tag to embed a variable from page_load into a
meta tag in the aspx source? Somehow I am not getting the value out of my
variable properly - probably not using quotes correctly or something simple,
but after a full day of trying every possible syntax under the sun, I hope
someone can help.

Page_Load:
this.myKeywords = "keyWordOne keyWordTwo keyWordThree";

aspx source:
<head runat="server">
<meta name="keyword" content="<%=myKeywords %>" id="metaKeyword"
runat="server" />
</head>

results (source at runtime):
<meta id="metaKeyword" name="keyword" content="<%=myKeywords %>" />

note, my problem is that the results should be the value in myKeywords, not
="<%=myKeywords %>" as shown above.
 
M

Michael Nemtsev

Hello Jay,

content='<%#myKeywords()%>'

Where myKeywords is the function, returning your data


J> Is it possible to use the <% %> tag to embed a variable from
J> page_load into a meta tag in the aspx source? Somehow I am not
J> getting the value out of my variable properly - probably not using
J> quotes correctly or something simple, but after a full day of trying
J> every possible syntax under the sun, I hope someone can help.
J>
J> Page_Load:
J> this.myKeywords = "keyWordOne keyWordTwo keyWordThree";
J> aspx source:
J> <head runat="server">
J> <meta name="keyword" content="<%=myKeywords %>" id="metaKeyword"
J> runat="server" />
J> </head>
J>
J> results (source at runtime):
J> <meta id="metaKeyword" name="keyword" content="<%=myKeywords %>" />
J> note, my problem is that the results should be the value in
J> myKeywords, not ="<%=myKeywords %>" as shown above.
J>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
G

Guest

Michael,
When you say to use a function, do you mean javascript? The only time I
have the value in the myKeywords variable is at Page_Load time. Are you
suggesting to use a function (or method for c#) with postback? How will the
method know what the value is (as Page_Load has already occurred)?
Rookie questions, sorry if this is the wrong group.
Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top