473,394 Members | 1,748 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,394 software developers and data experts.

Nesting Literal Control in anchor tags

Im running the following html snippet in my page...

<a href='<asp:Literal id="litSubRegionCode"
runat="server"></asp:Literal>'>Test</a>

When I flick back to designer view I get the 'Could not re-format page'
message.

How do I correctly nest the literal inside the anchor tag...

Thanks.

Nov 19 '05 #1
5 5097
Why are you trying to nest a literal control inside the "href"
property?
The HREF property is a string. If you need to set the href property
then consider making the <a tag a server control and set the property
via CodeBehind.
<a href="" runat="server" id="lnkTest">Test</a>

In your code behind there should be a variable declared as
protected HtmlAnchor lnkTest ;
If there is not then define it.
then set the property programmatically by going lnkTest.HRef = "....";

Nov 19 '05 #2
I want to use the literal control, not a htmlLink. I know I can use a
link, but I want to build a url and add my string in the middle. The
easiest way to do this is to use the literal control.

Anyone have an answer?

Thanks.

Nov 19 '05 #3
A Literal control cannot be put inside of an Attribute.
an ASPX follows basic HTMl/SGML based rules.
<root propery="<tag></tag>" is MALFORMED SGML and therefore is not
tolerated.

If you wish to use an existing value such as

<a href="/Dir/|/Action.aspx" runat="server" id="lnkTest">Test</a>

In your code behind there should be a variable declared as
protected HtmlAnchor lnkTest ;
If there is not then define it.
then set the property programmatically by going lnkTest.HRef = "....";

or since you said you wanted to "build a url and add my string in the
middle"
then do something like this
lnkTest.HRef = lnkTest.HRef.Replace("|", CurrentAction); // where
CurrentAction is some string that you want to dynamically insert or
maybe a variable from your web.config. etc

Nov 19 '05 #4
You may also be able to go <a href="Dir/<%= somevariable
%>/Action.aspx"></a> but having made the migration to asp.net along
time ago I would never do something like that so I am not sure as to
whether that is the exact syntax for asp.net or at what lifecycle stage
you would need to ensure somevariable has been set.

Nov 19 '05 #5
Hello Spondishy,

Why not use <asp:Hyperlink id="myLink" runat="server">Test</asp:Hyperlink>

and in your code-behind, do myLink.NavigateUrl = "~/Action.aspx?subregion="
+ subRegionVariable

--
Matt Berther
http://www.mattberther.com
Im running the following html snippet in my page...

<a href='<asp:Literal id="litSubRegionCode"
runat="server"></asp:Literal>'>Test</a>
When I flick back to designer view I get the 'Could not re-format
page' message.

How do I correctly nest the literal inside the anchor tag...

Thanks.


Nov 19 '05 #6

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

Similar topics

1
by: Jack Fox | last post by:
I am saving some formated html fragments (text, some formatting tags and anchor tags) in a SQL text column then writing it to a page. Something strange is happening with the anchor tags within the...
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...
1
by: JeffP | last post by:
Currently I have a user control which contain a <a href> link tag. I have a requirement to change the name property of the anchor tag to something like this: <a href="somepage.aspx" id"thislink"...
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...
5
by: paul.hester | last post by:
Hi all, I have a custom control with an overridden Render method. Inside this method I'm rendering each control in its collection using their RenderControl method. However, I'm running into a...
6
by: stephen.cunliffe | last post by:
Hi, I'm looking for opinion/facts/arguments on the correct nesting of UL, OL, & LI elements. For example, this is what I want (unordered list): * Item 1 * Item 2 * Item 3
4
by: Neo Geshel | last post by:
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...
5
by: Arch Stanton | last post by:
I'm trying to parse longitude and latitude into an anchor address string. It seems to be a straightforward enough idea, but I just can't seem to make it work. I've tried parsing literals into the...
1
by: Hetal | last post by:
Hi, I have been working on creating a dynamic table with controls on a ASP.NET webpage and i have been using literal controls to do that. The issue that i am facing is, when i have the Start and...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.