简体   繁体   English

在LoggedInTemplate内设置锚标记的href

[英]Set href of anchor tag inside of LoggedInTemplate

I am trying to create Dynamic link to user Profile, but it wont work as i expect. 我正在尝试创建指向用户个人资料的动态链接,但无法按我期望的那样工作。

i tryed this: 我尝试了这个:

    <li class='last' style="float:right"> <a id="loginLink2" runat="server" href="~/Profile/"+<asp:LoginName runat="server" />""
> ><asp:LoginName ID="LoginName1" runat="server" />  </a></l>>                                             <asp:LoginStatus ID="LoginStatus1" runat="server" OnLoggedOut="LoginStatus1_LoggedOut"
> LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/" />></li>

But its didnt work. 但它没有工作。 How do i get around this problem? 我如何解决这个问题? I could do it by ajax call to the server, but i want to avoid it if its possible. 我可以通过对服务器的ajax调用来做到这一点,但是如果可能的话,我想避免这样做。

You would have to manually set it from the server. 您必须从服务器手动设置它。 You could do this on loading the page via: 您可以通过以下方式在加载页面时执行此操作:

((HtmlLink)LoginView1.FindControl("loginLink2")).href = "~/Profile/" +
          this.User.Identity.Name;

The one part I don't know is what the server-side control that represents an <a runat="server"> ... but everything else should work. 我不知道的一部分是代表<a runat="server"> ...的服务器端控件是什么,但是其他所有东西都应该起作用。

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

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