如何访问非asp 来自代码后面的标签?

发布于 2024-12-13 08:13:51 字数 252 浏览 5 评论 0原文

我们正在做一个大项目,但我们有点陷入困境。 我需要从 PageLoad() 上的代码隐藏的 .ASPX 访问 根据我们刚刚通过 SQL 查询从数据库收集的值来分配正确的图像 (attrib src)。

我们无法使用 runat="server" 属性在服务器端查看它,因为我们有一堆使用 img 名称标签的 jQuery。

我确信有一种方法可以从代码隐藏视图中访问和修改图像的 src 属性?

We're working on a big project and we're stuck a bit here.
I need to access the <img>'s from an .ASPX from the code-behind on the PageLoad()
to assign the right image (attrib src) depending on the value we just collected from the DB from an SQL Query.

We can't use the runat="server" attribute to see it server side because we got a bunch of jQuery using the img name tag to work with.

I'm sure there's a way to access and modify the src attribute of the images from the code behind view?

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

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

发布评论

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

评论(3

愁杀 2024-12-20 08:13:51

您可以使用文字< /a> 控制输出图像元素。

您可以访问文字的值以从中提取(解析)任何信息并重写它。

You can use a Literal control to output the image element.

You can access the value of the literal to extract (parse out) any information from it and re-write it.

卸妝后依然美 2024-12-20 08:13:51

您可以在图像标记上使用 ClientIdMode=Static 属性。这样,您可以添加 runat=server 属性,并且仍然可以从 jquery 访问图像标签。

检查以下内容 文档了解更多信息。

You can use the ClientIdMode=Static property on your image tag. That way you can add the runat=server attribute and you can still access the image tag from your jquery.

Check the following documentation for more info.

风铃鹿 2024-12-20 08:13:51

要设置 src 属性,您必须通过发出 JavaScript 来重新呈现控件或操作。

To set the src attribute you will have to re-render the control or manipulate by emitting JavaScript.

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