Why this DataBind changes my code?

M

maury

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?
 
G

Guest

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;
 
M

maury

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
 
G

Guest

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
 
M

maury

&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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top