Neo Geshel wrote:
> Just moved to C# from VB.NET, frustrated to hell and back by inability
> to get much-copied (from about 20+ different resources) literal example
> to work.
>
> Master Page content:
>
> <meta name="keywords" content="<asp:Literal ID="ltrlKeywords"
> Runat="server" />"></meta>
>
> Code-Behind:
>
> using System;
> using System.Web;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.HtmlControls;
>
> public partial class MySiteMaster : System.Web.UI.MasterPage{
> protected void Page_Load (object sender, EventArgs e){
> ltrlKeywords.Text="This is a test";
> }
> }
>
>
> Resulting error:
>
> Compiler Error Message: CS0117:
> 'System.Web.UI.HtmlControls.HtmlGenericControl' does not contain a
> definition for 'Text'
>
> Why did I use a literal instead of focusing on the <meta> itself?
> Because I am using XHTML 1.1, and I cannot have any residual ID
> attributes hanging around (a meta element does not have an ID attribute,
> and making the meta have a runat="server" causes the ID to remain in the
> element after ASP.NET is finished with it)
>
> This error keeps occurring, even when I do cut-and-paste examples form
> such big-name books as Wrox ASP.NET 2.0 Pro.
>
> This is making me tear my hair out, and I have precious little of it
> left on top. Please help!!!
>
> TIA
> ...Geshel
It seems that there is some problem with the markup code. When you use
the Literal control from code behind, you get an error message referring
to the use of a HtmlGenericControl. It seems as the code does not
produde a Literal control at all.
You can put the Literal control in placeof the entire meta tag, and put
the html code for the meta tag into the Literal. That way you won't put
a server control inside an html tag, which might be the reason for your
problems.
--
Göran Andersson
_____
http://www.guffa.com