Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Bizarre literal.text error

Reply
Thread Tools

Bizarre literal.text error

 
 
Neo Geshel
Guest
Posts: n/a
 
      02-25-2007
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
--
************************************************** *******************
My return e-mail address is an automatically monitored spam honeypot.
Do not send e-mail there unless you wish to be reported as a spammer.
Please send all e-mail to my first name at my last name dot org, with
a subject-line of “NEWSGROUP REPLY FOR NEO GESHEL” (all uppercase).
************************************************** *******************
 
Reply With Quote
 
 
 
 
=?UTF-8?B?R8O2cmFuIEFuZGVyc3Nvbg==?=
Guest
Posts: n/a
 
      02-26-2007
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
 
Reply With Quote
 
 
 
 
Neo Geshel
Guest
Posts: n/a
 
      02-26-2007
Göran Andersson wrote:
> 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.
>


And that is exactly what I did, and it worked well; thanks.

However, I just want to edit the keywords of a meta tag; to drag a
random allotment from a database and assign them to a literal control.
In VB.NET the above code worked just peachy. I was able to dump them
directly into the meta tag field by using a literal between the content
quotes. Why wouldn't this work in C#? What could the difference be?

Also, when I removed all code-behind code, the presence of the literals
within the meta tags mutated the meta tags dramatically. The <,> symbols
were altered to &lt;,&gt; and it appeared that the literal had “melted”
(about the best description I can give!!!) into the meta tag (and had
given the meta tag an id, to boot). Why such bizarre behaviour????

TIA
...Geshel
--
************************************************** *******************
My return e-mail address is an automatically monitored spam honeypot.
Do not send e-mail there unless you wish to be reported as a spammer.
Please send all e-mail to my first name at my last name dot org, with
a subject-line of “NEWSGROUP REPLY FOR NEO GESHEL” (all uppercase).
************************************************** *******************
 
Reply With Quote
 
Neo Geshel
Guest
Posts: n/a
 
      02-26-2007
Neo Geshel wrote:
> Göran Andersson wrote:
>> 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.
>>

>
> And that is exactly what I did, and it worked well; thanks.
>
> However, I just want to edit the keywords of a meta tag; to drag a
> random allotment from a database and assign them to a literal control.
> In VB.NET the above code worked just peachy. I was able to dump them
> directly into the meta tag field by using a literal between the content
> quotes. Why wouldn't this work in C#? What could the difference be?
>
> Also, when I removed all code-behind code, the presence of the literals
> within the meta tags mutated the meta tags dramatically. The <,> symbols
> were altered to &lt;,&gt; and it appeared that the literal had “melted”
> (about the best description I can give!!!) into the meta tag (and had
> given the meta tag an id, to boot). Why such bizarre behaviour????
>
> TIA
> ...Geshel


To be more specific, the <,> of the literal, not the meta tag, had been
degraded into &lt; and &gt; entities. As such, the literal had “melted”
into the meta tag, severely mutating it.

...Geshel
--
************************************************** *******************
My return e-mail address is an automatically monitored spam honeypot.
Do not send e-mail there unless you wish to be reported as a spammer.
Please send all e-mail to my first name at my last name dot org, with
a subject-line of “NEWSGROUP REPLY FOR NEO GESHEL” (all uppercase).
************************************************** *******************
 
Reply With Quote
 
Tim Clark
Guest
Posts: n/a
 
      02-26-2007
You can't just stick server controls in the middle of attributes like
that. You probably want to do something like:
<meta name="keywords" content="<%=SetContent() %>" ></meta>
....

protected string SetContent()
{
return "This is a test";
}

> 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
> --
> ************************************************** *******************
> My return e-mail address is an automatically monitored spam honeypot.
> Do not send e-mail there unless you wish to be reported as a spammer.
> Please send all e-mail to my first name at my last name dot org, with
> a subject-line of "NEWSGROUP REPLY FOR NEO GESHEL" (all uppercase).
> ************************************************** *******************



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Really bizarre linking error! bajichuan@hotmail.com C++ 11 08-12-2007 11:02 AM
Bizarre error with cmd.CreateParameter audleman@quasika.net ASP .Net 0 04-18-2006 07:15 PM
RE: Bizarre error from help() Delaney, Timothy (Tim) Python 14 08-11-2005 10:20 PM
Bizarre error from help() Roy Smith Python 0 08-10-2005 03:02 AM
need help with bizarre error caught in debugger. execution is hanging omission9 Python 3 02-23-2004 08:42 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57