将变量连接到.NET中ASP超链接的末端

发布于 2025-02-08 21:14:23 字数 749 浏览 2 评论 0原文

我正在尝试自定义超链接,以在每个链接的末尾附加可变程序ID,具体取决于使用哪个程序ID。

我创建了我的超链接,并添加了wikilink.navagateurl为链接,加上可变程序密码,问题仅是附加链接,而不是带有程序ID的链接。

例如,如果程序ID为5(我们的变量),并且我在单击时运行此代码,则在 https:// www.example.com/ ,不要 https://www.example.com/5 添加了带有程序ID的链接

<asp:HyperLink ID="wikiLink" runat="server" Text="Link to Wiki page" </asp:HyperLink>
 protected void Page_Load(object sender, EventArgs e)
    {
        var ProgramID = 5;

        wikiLink.NavagateUrl  = "https://www.Example.com/" + ProgramID; 
    }

I am trying to customize my hyperlink to attach a variable Program Id at the end of each link depending on which Program Id is being used.

I Created my hyperlink and added the wikiLink.NavagateUrl to be the link plus the variable ProgrammId the issue is only the link is being attached and not the link with Program ID.

For example, if Program Id is 5(our variable) and I run this code the hyperlink when clicked goes to https://www.Example.com/ and not to https://www.Example.com/5 the link with the program id added

<asp:HyperLink ID="wikiLink" runat="server" Text="Link to Wiki page" </asp:HyperLink>
 protected void Page_Load(object sender, EventArgs e)
    {
        var ProgramID = 5;

        wikiLink.NavagateUrl  = "https://www.Example.com/" + ProgramID; 
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

屋檐 2025-02-15 21:14:23

看来您忘记使用'&gt;'关闭开放的超链接标签,并且您被拼写错误的超链接属性名称。尝试写入:

<asp:HyperLink ID="wikiLink" runat="server" Text="Link to Wiki page"></asp:HyperLink>

在网页和

wikiLink.NavigateUrl = "https://www.Example.com/" + ProgramID;

“ .cs”文件中。

It seems you forget to close the open hyperlink tag with '>' and that you are misspelled the hyperlink property name. Try to write:

<asp:HyperLink ID="wikiLink" runat="server" Text="Link to Wiki page"></asp:HyperLink>

in the web page and

wikiLink.NavigateUrl = "https://www.Example.com/" + ProgramID;

in the ".cs" file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文