Problems with the preprocessor directive for the ImgUrl property of an image in ASP.NET

I would like to parse a QueryString and put the ID value in the ImgUrl path, I try this code:

<asp:Image ID="imgImageNormal" runat="server" ImageUrl='<%# string.Format("ImageHandler.ashx?ID={0}",Request.QueryString["ID"].ToString()) %>'/>

But the result is no. I am not getting an error, but after viewing the page source this is the result for the image:

<img id="ctl00_ContentPlaceHolder1_imgImageNormal" src="" style="border-width:0px;" />

What am I doing wrong?

+3
source share
1 answer

Is this in the context of binding? If not, the syntax <%#...%>will not work. This code works:

<img ID="imgImageNormal" src=<%=string.Format("ImageHandler.ashx?ID={0}",Request.QueryString["ID"].ToString())%> />

: runat="server" src . , , , imageurl asp: image page_load.

, asp.net, : http://naspinski.net/post/inline-aspnet-tags-sorting-them-all-out-(3c25242c-3c253d2c-3c252c-3c252c-etc).aspx

+1

Source: https://habr.com/ru/post/1775647/


All Articles