简体   繁体   English

如何在ASP.NET中将Request.QueryString [“”]绑定到Eval()

[英]How to bind Request.QueryString[“”] to Eval() in ASP.NET

ImageUrl='<%#Eval("Name","../Master Pages/DisasterImages/") %>'+'<%#Eval("Request.QueryString["DisID"].ToString()/{0}") %>'

DisID is a folder name. DisID是文件夹名称。

What I want is to display the images in the directory. 我想要的是在目录中显示图像。 I have done it using a repeater control. 我使用转发器控件完成了它。 The problem is now I want to get the folder name in the QueryString. 问题是现在我想在QueryString中获取文件夹名称。 How can I do this? 我怎样才能做到这一点? Above is the code I have tried without achieving the desired outcome... 以上是我试过的代码而没有达到预期的结果......

Any help would appreciated. 任何帮助将不胜感激。

Thank you! 谢谢!

use <%= instead of <%#. 使用<%=而不是<%#。 Example: 例:

<%= Request.QueryString["DisID"] %>

I have noticed another issue with your code, you need to be careful when using quotes inside a string. 我注意到你的代码存在另一个问题,在字符串中使用引号时需要小心。 You need to escape them. 你需要逃脱它们。 Therefore 因此

"Request.QueryString["DisID"].ToString()/{0}"

should look like this 应该是这样的

"Request.QueryString[\"DisID\"].ToString()/{0}"

Notice the backslash that serves for escaping characters. 注意用于转义字符的反斜杠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM