AJAX中的ScriptManager用户控件 [英] AJAX ScriptManager in UserControl

查看:139
本文介绍了AJAX中的ScriptManager用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一个UpdatePanel它封装了一些其他控件一个用户控件。该用户控件将被用在一些页面已经有一个ScriptManager和其他网页没有一个ScriptManager。我想在用户控件自动将其自身的ScriptManager如果不存在。

I have a UserControl that contains an UpdatePanel which wraps some other controls. The UserControl will be used on some pages that already have a ScriptManager and other pages that do not have a ScriptManager. I'd like the UserControl to automatically bring its own ScriptManager if one does not exist.

我已经试过ScriptManager.GetCurrent,如果它返回null创建我自己的ScriptManager,并将其插入表格,但我不能找到一个地方及早在该用户的生命周期来运行这个code。我不断收到错误ID为uPnlContentList的控制需要一个ScriptManager在页面上。使用ScriptManager必须出现在任何需要它的控制了。每次我尝试加载页面。我已经尝试运行我的code的名额是OnInit,CreateChildControls中和pageLoad的,他们从来没有被调用,因为它到达之前死亡。

I have tried ScriptManager.GetCurrent and if it returns null i create my own ScriptManager and insert it into the Form but I can't find a place early enough in the UserControl's lifecycle to run this code. I keep getting the error "The control with ID 'uPnlContentList' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it." every time i try loading the page. The places i've tried running my code are OnInit, CreateChildControls and PageLoad and they never get called because it dies before reaching them.

我应该在哪里把这个检查?

Where should I put this check?

推荐答案

我不想来到这个在另一个方向,但你使用母版页?如果是的话,你有没有考虑把单一的ScriptManager它,正在做呢?

I hate to come at this in another direction, but are you using a master page? And if so, have you considered placing a single ScriptManager on it and being done with it?

这篇关于AJAX中的ScriptManager用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆