如何从 DNN 中的 .ascx Web 用户控件更新 ScriptManager?
我已经创建了一个需要在 .ascx 页面中使用的 Web 服务。 我不能只添加这个:
<asp:ScriptManager ID="OWUScripts" runat="server">
<Services>
<asp:ServiceReference Path="~/OWUDashboard.asmx" />
</Services>
</asp:ScriptManager>
因为那时我在页面上有多个 ScriptManager。 所以我做了一点研究,发现我需要将其添加到 Page_Load 事件中...
Dim myScriptManager As ScriptManager = ScriptManager.GetCurrent(Me.Page)
Dim objServiceReference As ServiceReference = New ServiceReference()
objServiceReference.Path = "~/MyService.asmx"
myScriptManager .Services.Add(objServiceReference)
但是我无法访问 Page_Load 事件,因为已经有一个预设(它是皮肤等)所以我抛出了 之间的代码
但是它给了我一个错误,说“预期声明”...我拿出了几行,它似乎是说它找不到 Me.Page (或者它为空)
关于我做错了什么有任何见解吗?
我可以像我一样从 访问 Me.Page 还是应该采用不同的方式?
I've created a Web Service that I need to use in my .ascx page. I can't just add this:
<asp:ScriptManager ID="OWUScripts" runat="server">
<Services>
<asp:ServiceReference Path="~/OWUDashboard.asmx" />
</Services>
</asp:ScriptManager>
Because then I have multiple ScriptManagers on the page. So I did a little research and found out that I need to add this to the Page_Load event...
Dim myScriptManager As ScriptManager = ScriptManager.GetCurrent(Me.Page)
Dim objServiceReference As ServiceReference = New ServiceReference()
objServiceReference.Path = "~/MyService.asmx"
myScriptManager .Services.Add(objServiceReference)
But I can't access the Page_Load event since there's already one pre-set (with it being a skin and all) So I threw the code between <script runat="server"></script>
However it's giving me an error saying "Declaration Expected"... I took out a few lines and it seemed to be saying it couldn't find Me.Page (Or it was coming up null)
Any insight as to what I'm doing wrong?
Can I access Me.Page from <script runat="server">
like I am or should I be doing it a different way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于这种情况,您可以使用 ScriptManagerProxy 类以声明方式添加引用。 只要“父”页面中已经定义了 ScriptManger,就会使用代理类。 使用 ScriptManagerProxy 的方式与使用常规 ScriptManager 的方式相同。 有关代理类的更多信息可以在此处找到。
标记示例:
Fur such cases there is a ScriptManagerProxy class that you can use to add references declaratively. The proxy class is used whenever there is already defined ScriptManger in a "parent" page. You work with the ScriptManagerProxy the same way as with the regular ScriptManager. More information regarding the proxy class can be found here.
Example markup: