使用 jQuery 将用户控件的输出返回为 HTML 或字符串
今天早上,我试图弄清楚如何使用 jQuery 从页面上的按钮更新用户控件。
我发布了这个问题
从本文中收集的信息:
< a href="http://www.codeproject.com/Articles/117475/Load-ASP-Net-User-Control-Dynamically-Using-jQuery" rel="nofollow noreferrer">http://www.codeproject.com/Articles/117475/Load-ASP-Net-User-Control-Dynamically-Using-jQuery
在发布该问题后我收到了出色的帮助,我现在有了使用 jQuery 将用户控件加载为页面的方法,使用 codeproject.com 文章中转换后的 .VB 示例。
但是...这不会渲染到浏览器中,Firebug 给出错误“元素必须包含在表单 runat=server 标记中”
所以我发布了这个问题:
自从发布后,我进一步考虑了它,并且相信事实上,由 codeproject 代码创建的 jQueryHandler 类向浏览器发送一个完整的页面。
遗憾的是,鉴于我并不真正理解该 codeproject 代码的实际用途,我无法弄清楚如何更改它。
我需要它做的根本不是返回一个 Page,而是返回一个 HTML 字符串,然后可以根据需要将其作为 HTML 直接粘贴到 div 中。
关于如何更改该代码以返回 HTML 字符串有什么想法吗?
(我使用的是asp.net 2.0和VB)
This morning I was trying to work out how to update a User Control from a button on a page using jQuery.
I posted this question
Refresh User Control with jQuery
From the info gleaned from this article:
http://www.codeproject.com/Articles/117475/Load-ASP-Net-User-Control-Dynamically-Using-jQuery
And the excellent help I received following posting that question, I now have a method of loading a User Control as a page with jQuery using the converted .VB example from the codeproject.com article.
However... this won't render into the browser, Firebug is giving the error "element must be contained within a form runat=server tag"
So I posted this question:
Since posting that though, I have thought about it further, and believe it is the fact that the jQueryHandler
class created by the codeproject code is send the browser a complete page.
Given that I sadly don't really understand what that codeproject code actually does I am having trouble working out how to alter it.
What I need it to do is not return a Page at all, but I guess, an HTML string, which can then be pasted directly as HTML into the div as required.
Any ideas as to how to alter that code to return an HTML string?
(I am using asp.net 2.0 and VB)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回发将导致整个页面刷新。既然您想避免这种情况,那么我建议使用 jquery 并动态创建选项 html 并将其绑定到
用户控件中的单击事件,只需键入对 js 文件的引用。
在脚本文件中你可以做这样的事情
The postback would cause a full page refresh. Since you are wanting to avoid that then what I would recommend is this use jquery and dynamically create the options html and bind that to a click event
in the user control just type a reference to a js file.
In the script file you can then do something like this