【问题标题】:How can I include the result of an expression in a NavigateUrl link?如何在 NavigateUrl 链接中包含表达式的结果?
【发布时间】:2019-06-22 12:27:30
【问题描述】:

我需要能够将用户的 id 作为参数包含在 url 中。我不知道如何将用户 ID 传递给 NavigateUrl 链接。

我尝试了以下代码,但 SendEmailAddress 变量没有从表达式中获取用户 ID。我检查了表达式,它确实返回了用户 ID,但我似乎无法弄清楚如何将它放入 url。

<xsl:variable name="sendEmailAddress" select="<%: Context.User.Identity.GetUserName()%>">
<asp:HyperLink NavigateUrl='<%# String.Format("https://www.43534353portal.com/s/w/login/question?email=", "$sendEmailAddress") %>' Text="[Change Preferences]" runat="server" />

我希望能够连接 "https://www.43534353portal.com/s/w/login/question?email=" 和 的结果,并将其作为 NavigateUrl 指向的 url。

【问题讨论】:

    标签: html asp.net xml


    【解决方案1】:

    答案很简单。使用 href 代替 asp:HyperLink(见下面的代码)。

    <a href=<%:"https://www.43534353portal.com/s/w/login/question?email=" + Context.User.Identity.GetUserName()%>>[Change Preferences]</a>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-25
      • 1970-01-01
      • 2013-11-21
      • 1970-01-01
      • 2021-10-27
      • 2013-05-07
      • 2013-01-01
      • 2017-10-25
      相关资源
      最近更新 更多