有没有办法使用 C# 脚本来更改标签的内部 html?

发布于 2024-11-19 01:28:06 字数 496 浏览 2 评论 0原文

我需要将标签的内容从“购物车”更改为“下载”。通常这只是通过手动更改 html 来完成,但我无权访问它。相反,我可以访问在服务器上运行的 C# 脚本的一小部分。有没有办法通过 C# 脚本更改标签的内容?

编辑

好的,这是我必须更改的代码

<a id="ctl00_ctl00_PageHeader1_shoppingCart_anchor" class="navBarButton"
   href="javascript:__doPostBack('ctl00$ctl00$PageHeader1$shoppingCart$anchor','')">
      Shopping Cart</a>

,这是脚本标头的内容,

<script language="C#" runat="server">

希望这能提供更多上下文,我真的只需要知道它是否可能,所以任何帮助都会很棒

I need to change the contents of an tag from "Shopping Cart" to "Downloads". Normally this would just be done by changing the html by hand but i don't have access to that. Instead i have access to a small snip of a C# script that runs at the server. Is there anyway to change the contents of the tag through a C# script?

EDIT

Okay here is the code i have to change

<a id="ctl00_ctl00_PageHeader1_shoppingCart_anchor" class="navBarButton"
   href="javascript:__doPostBack('ctl00$ctl00$PageHeader1$shoppingCart$anchor','')">
      Shopping Cart</a>

And here is what the script header has

<script language="C#" runat="server">

Hopefully this gives some more context, i really just need to know if its possible or not so any help at all would be great

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

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

发布评论

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

评论(2

半城柳色半声笛 2024-11-26 01:28:06

与其他答案一样,这取决于服务器端代码实际提供的内容

您也许能够输出一些 javascript 来定位有问题的控件,并重置其内容,可能使用类似这样的内容...

document.getElementById('myTagId').innerHTML = 'Downloads';

但是,在不知道 HTML 是什么的情况下,我无法为您提供更多帮助。

As with other answers, this will depend on what the server side code is actually providing.

You might be able to output some javascript to locate the control in question, and reset its contents, possibly with something like this...

document.getElementById('myTagId').innerHTML = 'Downloads';

Without seeing what the HTML is, though, I can't help you much more than that.

魔法少女 2024-11-26 01:28:06

您可以使用控件代替标准 HTML,并在需要时更改其内容;

<asp:Literal id="litHeading" runat="server">Shopping Cart</asp:Literal>

并在 code_behind 中

litHeading.Text = "Downloads";

You could use an control in place of the standard HTML and change the contents of this as and when required;

<asp:Literal id="litHeading" runat="server">Shopping Cart</asp:Literal>

and in code_behind

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