473,624 Members | 2,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:L iteral ID="ltrlKeyword s"
Runat="server" />"></meta>

Code-Behind:

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;

public partial class MySiteMaster : System.Web.UI.M asterPage{
protected void Page_Load (object sender, EventArgs e){
ltrlKeywords.Te xt="This is a test";
}
}
Resulting error:

Compiler Error Message: CS0117:
'System.Web.UI. HtmlControls.Ht mlGenericContro l' 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 2305
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:L iteral ID="ltrlKeyword s"
Runat="server" />"></meta>

Code-Behind:

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;

public partial class MySiteMaster : System.Web.UI.M asterPage{
protected void Page_Load (object sender, EventArgs e){
ltrlKeywords.Te xt="This is a test";
}
}
Resulting error:

Compiler Error Message: CS0117:
'System.Web.UI. HtmlControls.Ht mlGenericContro l' 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 HtmlGenericCont rol. 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:L iteral ID="ltrlKeyword s"
Runat="serve r" />"></meta>

Code-Behind:

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;

public partial class MySiteMaster : System.Web.UI.M asterPage{
protected void Page_Load (object sender, EventArgs e){
ltrlKeywords.Te xt="This is a test";
}
}
Resulting error:

Compiler Error Message: CS0117:
'System.Web.UI .HtmlControls.H tmlGenericContr ol' 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 HtmlGenericCont rol. 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:L iteral ID="ltrlKeyword s"
Runat="server " />"></meta>

Code-Behind:

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;

public partial class MySiteMaster : System.Web.UI.M asterPage{
protected void Page_Load (object sender, EventArgs e){
ltrlKeywords.Te xt="This is a test";
}
}
Resulting error:

Compiler Error Message: CS0117:
'System.Web.U I.HtmlControls. HtmlGenericCont rol' 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 HtmlGenericCont rol. 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="<%=Set Content() %>" ></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:L iteral ID="ltrlKeyword s"
Runat="server" />"></meta>

Code-Behind:

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;

public partial class MySiteMaster : System.Web.UI.M asterPage{
protected void Page_Load (object sender, EventArgs e){
ltrlKeywords.Te xt="This is a test";
}

}

Resulting error:

Compiler Error Message: CS0117:
'System.Web.UI. HtmlControls.Ht mlGenericContro l' 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
1561
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: "inputbox.value = numq+(ag)-(cw)-(cc);" This was needed in IE6 but not in any other browser I tried.
6
6927
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 about a LiteralControl and a Label? Other than the lack of being able to format the Literal control's text, I don't see much of a difference in the documentation. TIA, --
5
2849
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 according to the width of the literal, which is the width then it is put on the page. The other day I played with this and had no problem. I assigned the text to the literal and it went onto the page as it should have. I tried using html tags...
3
4139
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, the label needs to stay the same size, I just need to resize the text. Thanks to all that help!
0
8249
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8685
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8348
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2613
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.