如何访问非asp
来自代码后面的标签?
我们正在做一个大项目,但我们有点陷入困境。 我需要从 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用
文字
< /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.
您可以在图像标记上使用
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.
要设置 src 属性,您必须通过发出 JavaScript 来重新呈现控件或操作。
To set the
src
attribute you will have to re-render the control or manipulate by emittingJavaScript
.