Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Difficulty with LinkButton.Attribute[] usage

Reply
Thread Tools

Difficulty with LinkButton.Attribute[] usage

 
 
Guest
Posts: n/a
 
      04-20-2004
Hello,

I am trying to create an anchor tag on a page that look like this:

<a id="some_id" onSomeAction="this.href='page.aspx?a=1&b=2'">some_ text</a>

I tried to accomplish this using System.Web.UI.WebControls.LinkButton object
and using the following statement:

linkbutton.Attributes ["onSomeAction"] = "this.href='page.aspx?a=1&b=2'";

When run, the '&' character gets translated to '&amp;' . As a result, the
output on the page looks like this:

<a id="some_id"
onSomeAction="this.href='page.aspx?a=1&amp;b=2'">s ome_text</a>


Would anyone be able to tell me how to disable the translation of the '&'
character.

Thanks


 
Reply With Quote
 
 
 
 
Scott Mitchell [MVP]
Guest
Posts: n/a
 
      04-21-2004
> I am trying to create an anchor tag on a page that look like this:
>
> <a id="some_id" onSomeAction="this.href='page.aspx?a=1&b=2'">some_ text</a>
>
> I tried to accomplish this using System.Web.UI.WebControls.LinkButton object
> and using the following statement:
>
> linkbutton.Attributes ["onSomeAction"] = "this.href='page.aspx?a=1&b=2'";
>
> When run, the '&' character gets translated to '&amp;' . As a result, the
> output on the page looks like this:
>
> <a id="some_id"
> onSomeAction="this.href='page.aspx?a=1&amp;b=2'">s ome_text</a>


I used Reflector to look at the code for the AttributeCollection's
Render() method. Essentially, it loops through the added attributes,
and does a writer.WriteAttribute(...) call, passing in the key and value
of the attribute, where writer is an HtmlTextWriter instance.

Now, here's the rub. The HtmlTextWriter's WriteAttribute() method takes
in as a third parameter a Boolean indicating whether or not the HTML
passed in should be HTML encoded. The AttributeCollection's Render()
method, unfortunately, passes in a hard-coded value of true.

There may be an elegant workaround, but I can't think of one off the top
of my head. Sorry!

--

Scott Mitchell
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
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
What is the difference between Memory Usage and Heap Usage in my JVMMetrics ? Krist Java 8 02-10-2010 12:44 AM
retrieving CPU Usage and Memory Usage information in JAVA hvt Java 0 03-13-2007 01:09 PM
retrieving CPU Usage and Memory Usage information in JAVA hvt Java 0 03-13-2007 01:07 PM
Webchecker Usage - a problem with local usage Colin J. Williams Python 1 02-26-2004 12:28 AM
Need help on memory usage VS PF usage metfan Java 2 10-21-2003 01:58 PM



Advertisments