标签内的链接 - 包括额外的功能

时间:2010-02-09 13:19:36

标签: asp.net hyperlink label

我在前面有以下代码,它提供了一些模糊信息,并创建了一个用户可以点击的链接,并将它们发送到指定的页面。

 <asp:Label ID="tbxFindOutMore" runat="server" 
            text="If you are already a member, please <a href ='Reporting/Login.aspx' target=_blank style=color:black>click here</a> to login to your bespoke reporting" 
            Font-Names="Trebuchet MS" Font-Size="12px" ForeColor="Black"></asp:Label>

之前我使用它作为链接按钮,后面有以下点击代码,使窗口最大化为全屏:

    Page.ClientScript.RegisterStartupScript
(this.GetType(), "openwindow", "win = window.open('Reporting/Login.aspx');win.moveTo(0,0); win.resizeTo(window.screen.availWidth, window.screen.availHeight)", true);

我如何将此功能纳入我正在使用的asp:标签中?

3 个答案:

答案 0 :(得分:1)

为什么不在客户端做这一切?

<script type="text/javascript" language="javascript">
function openReportingLogin() {
  win = window.open('Reporting/Login.aspx');
  win.moveTo(0,0);
  win.resizeTo(window.screen.availWidth, window.screen.availHeight);
}
</script>
<span style="font-family: Trebuchet MS; font-size: 12px; color: black;">If you are already a memeber, please <a style="color: black;" href="javascript:openReportingLogin();">click here</a> to login to your bespoke reporting</span>

答案 1 :(得分:0)

您不应该在标签的Text属性中添加标记。相反,像通常使用HTML一样构建它(我看不出这是<asp:Label />的原因:

<script>
function openwindow()
{
    win = window.open('Reporting/Login.aspx');
    win.moveTo(0,0);
    win.resizeTo(window.screen.availWidth, window.screen.availHeight);
}
</script>
<span style="font-family: Trebuchet MS; font-size: 12px; color: black">
    If you are already a member, please
    <a href="javascript:openwindow();" target="_blank" style="color: black">click here</a>
    to login to your bespoke reporting
</span>

答案 2 :(得分:0)

我同意Codesleuth。

如果您想在服务器端操作,只需将runat =“server”属性添加到相应的html标记中。

克里斯