Why this DataBind changes my code?

Discussion in 'ASP .Net' started by maury, Jan 27, 2010.

  1. maury

    maury 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?
     
    maury, Jan 27, 2010
    #1
    1. Advertising

  2. On Jan 27, 3:31 pm, maury <> 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;
     
    Alexey Smirnov, Jan 27, 2010
    #2
    1. Advertising

  3. maury

    maury Guest

    On 27 Gen, 17:16, Alexey Smirnov <> 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
     
    maury, Jan 27, 2010
    #3
  4. On Jan 27, 5:36 pm, maury <> wrote:
    > On 27 Gen, 17:16, Alexey Smirnov <> 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
     
    Alexey Smirnov, Jan 27, 2010
    #4
  5. maury

    maury Guest

    On 27 Gen, 18:02, Alexey Smirnov <> 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
     
    maury, Jan 28, 2010
    #5
  6. On Jan 28, 11:03 pm, maury <> wrote:
    > On 27 Gen, 18:02, Alexey Smirnov <> 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.
     
    Alexey Smirnov, Jan 29, 2010
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QWF5dXNoIFB1cmk=?=

    Why databind is required while editing datagrid?

    =?Utf-8?B?QWF5dXNoIFB1cmk=?=, Mar 19, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,810
    Elton Wang
    Mar 19, 2005
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    991
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,258
    Smokey Grindel
    Dec 2, 2006
  4. Rathtap

    Databind Error -- cannot figure out why.

    Rathtap, Sep 8, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    157
    Alvin Bruney
    Sep 15, 2003
  5. Michael
    Replies:
    0
    Views:
    247
    Michael
    Dec 29, 2003
Loading...

Share This Page