在Asp.net中的ASP内容文件中使用服务器端脚本 [英] use of serverside script in asp content file in Asp.net
本文介绍了在Asp.net中的ASP内容文件中使用服务器端脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是可能的,<%%>用于将QueryString ID分配给src"img"标记,例如以下代码:
it is possible,i ues <% %> for assign QueryString ID,to src "img" tag such as below code:
<form id="form1" runat="server">
<div>
<img src="Default.aspx?ID=<%Request.QueryString[ID]%>/>
</div>
</form>
推荐答案
假定ID是键,而不是表单/控件上的属性,则应该起作用:
Assuming ID is the key and not a property on the form/control this should work:
<img src=''Default.aspx?ID=<%Request.QueryString["ID"]%>'' />
您可能需要<%=
而不是<%
我不记得了,我也无法测试:VS目前在我的计算机上已损坏...
You might need <%=
rather than <%
I can''t remember, and I can''t test: VS is currently broken on my machine...
尽管代码很丑陋,但您应该避免这样做.一个更好的主意是在页面上放置一个文字控制,并在后面的代码中设置它的值.或使用ASP.NET图像控件,并在后面的代码中设置它的URL.
This is very ugly code though, you should try to avoid doing it. A better idea is to put a literal contol on your page, and set it''s value in your code behind. Or use the ASP.NET image control, and set it''s URL in the code behind.
这篇关于在Asp.net中的ASP内容文件中使用服务器端脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文