输入丢失SRC [英] input losing src
本文介绍了输入丢失SRC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我用下面的code,而不=服务器输入的src工作正常,我看到的图像未来通过。
If I use the following code without runat="server" the input's src works fine and I see the image coming through.
<div><input id="testButton" type="image" src="<%=TestButtonImageUrl %>" onserverclick="RedirectTest" /></div>
网址是 https://fpdbs.paypal.com/dynamicimageweb?cmd=_dynamic-图片
但是,如果我把=服务器中,由于某种原因,我得到这个的网址:
But if I put the runat="server" in, for some reason, I get this for the url:
<div><input id="testButton" type="image" src="<%=TestButtonImageUrl %>" onserverclick="RedirectTest" runat="server" /></div>
网址是的http://本地主机/%3C%= lButtonImageUrl%20 %% 3E
推荐答案
您无法使用&LT;%=%&GT;
语法服务器控件(包括标准的HTML元素与 =服务器
)。你有两个选择:
You cannot use the <%= %>
syntax with server controls (including standard HTML elements with runat="server"
). You have two choices:
- 在后面的code访问控制(作为<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlinputcontrol_members%28VS.80,lightweight%29.aspx\"相对=nofollow>
HtmlInputControl
),并使用指定src属性的<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlcontrol.attributes%28VS.80,lightweight%29.aspx\"相对=nofollow>属性
属性:imageControl.Attributes [SRC] =值;
- 使用数据绑定语法指定属性(
SRC =&LT;%#%&gt;中
),并调用imageControl.DataBind()
从后面
- Access the control in the code behind (as an
HtmlInputControl
) and assign the src attribute using theAttributes
property:imageControl.Attributes["src"] = value;
- Assign the attribute using the databinding syntax (
src="<%# %>"
) and callimageControl.DataBind()
from the code behind
这篇关于输入丢失SRC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文