如何在href中添加服务器端变量并将其用于? [英] How do I add a server side variable to and use it in href?

查看:281
本文介绍了如何在href中添加服务器端变量并将其用于?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是asp.net的新手。我的代码中会有一个变量。



Dim foldername As String =new folder



我试图将此变量添加到转发器中的锚点href以形成URL:



href =<%#Uploaded-files / + Eval(foldername)+/缩略图/%>但现在可以使用。



任何帮助都将非常感谢。我需要一个简短的指南有完整的服务器端代码和html代码如何做到这一点。再次感谢你。





添加了代码块[/ edit]

Hi there, I'm new to asp.net. I'll have a variable in my code.

Dim foldername As String = "new folder"

I have tried to add this variable to an anchor href in a repeater to form a Url as:

href="<%#"Uploaded-files/" + Eval("foldername") + "/thumbnails/" %> but to now avail.

Any help will be much appreciated. Please I need a short guide with full serverside code and html code on how to do this. Once again thank you.


[edit]Code block added[/edit]

推荐答案

删除 Eval ,' +'(使用 system.Format ),考虑使用 Server.MapPath

< a href =http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.mappath.aspx> http://msdn.microsoft.com/en-us/library/system.web .httpserverutility.mappath.aspx [ ^ ]。



阅读Web和ASP.NET的工作原理从一开始就;我怀疑你真的需要它。



-SA
Remove Eval, '+' (use system.Format), consider using Server.MapPath:
http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.mappath.aspx[^].

Read on how Web and ASP.NET works from the very beginning; I suspect you really need it.

—SA


这篇关于如何在href中添加服务器端变量并将其用于?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆