ASP.NET AJAX RC and ScriptControls

Posted by: Glavs Blog, on 21 Dec 2006 | View original | Bookmarked: 0 time(s)

In a previous post, I talked about how to go about creating your own ExtenderControls. Lately, I have been busy creating another control to add into the Ajax Control Toolkit, however this control is based off a ScriptControl.

In previous releases of ASP.NET AJAX, you needed to implement the IScriptControl interface. This meant implementing 2 methods (in similar fashion to extender controls). These methods are the:

IEnumerable<ScriptDescriptor> GetScriptDescriptors();

IEnumerable<ScriptReference> GetScriptReferences();

And also, you needed to provide code similar to the following in the Pre-Render event:

ScriptManager.GetCurrent(Page).RegisterScriptControl<YourScriptControl>(this);

in order to register your control with the ScriptManager control. In the latest RC release, when implementing this interface, you also need to do the following code:

ScriptManager.GetCurrent(Page).RegisterScriptDescriptors(this);

to also register your ScriptDescriptors and basically register your instance script with associated properties. So your Pre-Render event looks like:

protected override void OnPreRender(EventArgs e)
{
   base.OnPreRender(e);

   ScriptManager.GetCurrent(Page).RegisterScriptControl<YourScriptControl>(this);
   ScriptManager.GetCurrent(Page).RegisterScriptDescriptors(this);
}

While this is required if implementing the IScriptControl interface, the RC release of ASP.NET Ajax also provides a base ScriptControl class that you can inherit from. What this means is that you still have to implement the 2 methods:

IEnumerable<ScriptDescriptor> GetScriptDescriptors();

IEnumerable<ScriptReference> GetScriptReferences();

but you dont have to provide the extra registration steps within the Pre-Render event. So inheriting from the System.Web.UI.ScriptControl class means a little less work, which is always good for someone as lazy as myself.

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: Ajax | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 1295 | Hits: 84

Similar Posts

  • DevReach Follow-up, Part I more
  • Make SharePoint 2007 Act Like SharePoint 2010, Updated more
  • Gaia Ajax 3.6 Alpha released: Ajax GridView and Adaptive Rendering ++ more
  • Telerik Introduces Free Web Testing Framework for ASP.NET AJAX and Silverlight more
  • Results of AJAX Statistic for .NET Development more
  • Ajax survey 2009: jQuery and MS Ajax are almost tied more
  • Survey: Ajax usage among .NET developers in 2009 more
  • Survey: Ajax usage among .NET developers in 2009 more
  • A lovely couple (of architecture books) more
  • Ajax.NET Professional and ASP.NET MVC more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD