【问题标题】:Passing through value in href在 href 中传递值
【发布时间】:2015-04-13 00:38:58
【问题描述】:

如何通过我的 ASP.NET 工作的 XAML 中的 href 标记传递值?
我试过这个:

 <a href='profile.aspx?ID=<%#HttpContext.Current.Session["id"]%>'>Profile</a>

但是 URL 显示为 "profile.aspx?ID="

我做错了什么?

【问题讨论】:

  • 你有没有调试过传递给它的变量是什么?
  • @Quill 是的,变量是 44
  • 您的会话是否超时?
  • @Quill 不,它仍然存在
  • “我的 ASP.NET 工作的 XAML”?通常对于 ASP.Net,它会是 ASPX /WebForms 或 CSHTML(Razor)/ASP.Net MVC ... 澄清你的意思是“XAML”会很好。

标签: c# asp.net url


【解决方案1】:

要使您的代码块与# 正常工作,您需要调用DataBind 方法。或者,您可以将代码块与= 一起使用,它应该适合您:-

 <a href='profile.aspx?ID=<%= HttpContext.Current.Session["id"]%>'>Profile</a>

【讨论】:

    猜你喜欢
    • 2021-09-11
    • 2017-02-02
    • 1970-01-01
    • 2020-07-08
    • 1970-01-01
    • 2020-05-17
    • 2018-07-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多