Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Nesting Literal Control in anchor tags

Reply
Thread Tools

Nesting Literal Control in anchor tags

 
 
Spondishy
Guest
Posts: n/a
 
      03-21-2005
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.

 
Reply With Quote
 
 
 
 
recoil@community.nospam
Guest
Posts: n/a
 
      03-21-2005
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 = "....";

 
Reply With Quote
 
 
 
 
Spondishy
Guest
Posts: n/a
 
      03-21-2005
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.

 
Reply With Quote
 
recoil@community.nospam
Guest
Posts: n/a
 
      03-21-2005
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

 
Reply With Quote
 
recoil@community.nospam
Guest
Posts: n/a
 
      03-21-2005
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.

 
Reply With Quote
 
Matt Berther
Guest
Posts: n/a
 
      03-21-2005
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.
>




 
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
Re: Use a literal as an HTML anchor string HillBilly ASP .Net 1 08-13-2008 04:31 PM
literal & chanracter in anchor tag name =?Utf-8?B?SmVmZlA=?= ASP .Net 1 04-24-2006 09:00 PM
Module.nesting -> Kernel#nesting Trans Ruby 10 09-16-2005 12:21 AM
What's wrong with rpc-literal? Why use doc-literal? Anonieko Ramos ASP .Net Web Services 0 09-27-2004 09:06 AM
Problem overriding render method to format literal content of nested tags in custom control Stephen Miller ASP .Net Building Controls 12 01-20-2004 08:52 AM



Advertisments