Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Why this DataBind changes my code? (http://www.velocityreviews.com/forums/t713034-why-this-databind-changes-my-code.html)

maury 01-27-2010 02:31 PM

Why this DataBind changes my code?
 
Hello, I have a web form page with something like this
<a id="link" runat="server" href='<%# String.Concat("pag.aspx?
tipo1=1&amp;tipo2=2") %>'>xxx</a>

on the Page_Load, I have this code to execute the databind
link.DataBind();

but the generated code is far from I would like to be, I would like to
have this code
<a href="pag.aspx?tipo1=1&amp;tipo2=2" id="link">xxx</a>

instead I can see in the html source of the page
<a href="pag.aspx?tipo1=1&tipo2=2" id="link">xxx</a>

(this is a problem for me...)

any ideas?

Alexey Smirnov 01-27-2010 04:16 PM

Re: Why this DataBind changes my code?
 
On Jan 27, 3:31*pm, maury <i...@talo.it> wrote:
> Hello, I have a web form page with something like this
> * * <a id="link" runat="server" href='<%# String.Concat("pag.aspx?
> tipo1=1&amp;tipo2=2") %>'>xxx</a>
>
> on the Page_Load, I have this code to execute the databind
> * * * * link.DataBind();
>
> but the generated code is far from I would like to be, I would like to
> have this code
> * * <a href="pag.aspx?tipo1=1&amp;tipo2=2" id="link">xxx</a>
>
> instead I can see in the html source of the page
> * * <a href="pag.aspx?tipo1=1&tipo2=2" id="link">xxx</a>
>
> (this is a problem for me...)
>
> any ideas?


Hm, I don't know why you may need it but you can try

&amp;amp;

maury 01-27-2010 04:36 PM

Re: Why this DataBind changes my code?
 
On 27 Gen, 17:16, Alexey Smirnov <alexey.smir...@gmail.com> wrote:
> Hm, I don't know why you may need it but you can try
>
> &amp;amp;


GREAT! This is a great idea! It works!!!!

But can you explain me what's the problem with my code?

Thanks


Alexey Smirnov 01-27-2010 05:02 PM

Re: Why this DataBind changes my code?
 
On Jan 27, 5:36*pm, maury <i...@talo.it> wrote:
> On 27 Gen, 17:16, Alexey Smirnov <alexey.smir...@gmail.com> wrote:
>
> > Hm, I don't know why you may need it but you can try

>
> > &amp;amp;

>
> GREAT! This is a great idea! It works!!!!
>
> But can you explain me what's the problem with my code?
>
> Thanks


&amp; is an html code of & and it seems that IDE replaced it here
because it thinks you makes an url. Why do you use String.Concat
method there? Maybe this is the reason

maury 01-28-2010 10:03 PM

Re: Why this DataBind changes my code?
 
On 27 Gen, 18:02, Alexey Smirnov <alexey.smir...@gmail.com> wrote:
> &amp; is an html code of & and it seems that IDE replaced it here
> because it thinks you makes an url. Why do you use String.Concat
> method there? Maybe this is the reason


This is only an example page, the real code is much more
complicated...

Note that also the html control <img ...runat='server'
has the same behaviour but <asp:Image
web control isn't affected by this problem, it renders fine...

bye


Alexey Smirnov 01-29-2010 08:07 AM

Re: Why this DataBind changes my code?
 
On Jan 28, 11:03*pm, maury <i...@talo.it> wrote:
> On 27 Gen, 18:02, Alexey Smirnov <alexey.smir...@gmail.com> wrote:
>
> > &amp; is an html code of & and it seems that IDE replaced it here
> > because it thinks you makes an url. Why do you use String.Concat
> > method there? Maybe this is the reason

>
> This is only an example page, the real code is much more
> complicated...
>
> Note that also the html control *<img ...runat='server'
> has the same behaviour but <asp:Image
> web control isn't affected by this problem, it renders fine...
>
> bye


Please ignore my last comment. This, of course, comes not from IDE,
but from ASP.NET. When html control has runat="server" ASP.NET does
html-decoding. Try to remove runat="server" from the link and see what
happens.


All times are GMT. The time now is 01:41 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.