开发者

Question about inline aspx tags

开发者 https://www.devze.com 2023-01-21 19:07 出处:网络
I have this div that\'s got a style attribute..In that I am setting it\'s background image by calling a function from code behind..

I have this div that's got a style attribute..In that I am setting it's background image by calling a function from code behind..

<div id="id1" style = "background-image: url(<%=GetImage()%>);"></div>

now when I add runat="server"开发者_运维知识库 attribute in this div..it shows the Image path as method name itself and not http://localhost/myweb/images/image.jpg

when I remove runat..image path displays alright..Isn't the runat supposed to be there because it's got inline aspx tag ??? I am confused.


Runat controls whether a control instance will be created server side. Dynamic injection directives such as <%=%> are always processed whether runat is set or not.


No, runat is not supposed to be there. Since you do not need to access this control on server side, you do not need it.

0

精彩评论

暂无评论...
验证码 换一张
取 消