如何从 DNN 中的 .ascx Web 用户控件更新 ScriptManager?

发布于 2024-07-24 14:52:45 字数 897 浏览 11 评论 0原文

我已经创建了一个需要在 .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 (或者它为空)

关于我做错了什么有任何见解吗?

我可以像我一样从

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 技术交流群。

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

发布评论

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

评论(1

给我一枪 2024-07-31 14:52:45

对于这种情况,您可以使用 ScriptManagerProxy 类以声明方式添加引用。 只要“父”页面中已经定义了 ScriptManger,就会使用代理类。 使用 ScriptManagerProxy 的方式与使用常规 ScriptManager 的方式相同。 有关代理类的更多信息可以在此处找到。

标记示例:

<asp:ScriptManagerProxy runat="server" ID="Manager">
<Scripts>
    <asp:ScriptReference Path="~/JScript.js" />
</Scripts>
</asp:ScriptManagerProxy>

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:

<asp:ScriptManagerProxy runat="server" ID="Manager">
<Scripts>
    <asp:ScriptReference Path="~/JScript.js" />
</Scripts>
</asp:ScriptManagerProxy>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文