473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Bizarre literal.text error

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 <metaitself?
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).
************************************************** *******************
Feb 25 '07 #1
4 2295
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 <metaitself?
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
Feb 26 '07 #2
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 <metaitself?
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).
************************************************** *******************
Feb 26 '07 #3
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 <metaitself?
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).
************************************************** *******************
Feb 26 '07 #4
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 <metaitself?
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).
************************************************** *******************

Feb 26 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Al Reynolds | last post by:
Afternoon, In an earlier thread (http://tinyurl.com/5v4aa), I described a problem I was having which was rather bizarrely solved by changing the line: "inputbox.value = numq+ag-cw-cc;" to:...
6
by: Joe | last post by:
I know that the Literal control will not render a <span> tag so I can not format its text. Other than this, what is the difference betwen the Literal control and the LiteralControl Control? How...
5
by: Mark A. Sam | last post by:
Hello, I am trying to use a literal control to past test onto a page from several buttons, so that each button displays something different. The problem I am encountering is that the text wraps...
3
by: TheGuyInUrCloset | last post by:
I have a box that has a predetermined size. Is there anyway I can automatically size the text to make it the largest it can, while still fitting inside the label's size? I cannot auto size the label,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.