Help get this topic noticed by sharing it on Twitter, Facebook, or email.
I’m puzzled

Wrapping ASP.Net AJAX Toolkit Control For Use In COT Application

I'm trying to wrap one of the ASP.Net AJAX Control Toolkit controls (ColorPicker) within a wrapper control (ColorPicker.ascx), so I can bind it to a field using the Editor property. Created the wrapper user control via COT, generated app, edited the files to include the TextBox and AJAX Extender. However, whenever the control is attempted to be used, the following error shows up where the control should be...

Unhandled Execution Error 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException:

Source Error:

Line 92: }
Line 93: if (c == null)
Line 94: throw new HttpException(404, String.Empty);
Line 95: else
Line 96: {

Source File: c:\Users\xxxxx\Documents\Code OnTime\Projects\Web App Factory\NPTProjectTracking\AMAT\Web\ControlHost.cs Line: 94

Stack Trace:

[HttpException (0x80004005)]
AMAT.Web.ControlHost.OnInit(EventArgs e) in c:\Users\xxxxx\Documents\Code OnTime\Projects\Web App Factory\NPTProjectTracking\AMAT\Web\ControlHost.cs:94
System.Web.UI.Control.InitRecursive(Control namingContainer) +140
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +480

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

I'm wondering since this snippet is present in the ControlHost.cs file...

object[] editorAttributes = c.GetType().GetCustomAttributes(typeof(AquariumFieldEditorAttribute), true);
if (editorAttributes.Length == 0)
c = null;

...if that is why this why the c value is null. I noticed the RichEditor control has those values instantiated later on in the code, and the c object is also given an editor instance. However, since I'm using ColorPicker, my control doesn't get caught and remains null.

I'm trying to avoid having to use any custom jQuery for the color picker (why should I as the AJAX Control Toolkit is already in every COT project by default?).


<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ColorPicker.ascx.cs" Inherits="Controls_ColorPicker"  %>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<ajaxToolkit:ColorPickerExtender runat="server"
TargetControlID="TextBox1" />


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Controls_ColorPicker : System.Web.UI.UserControl

protected void Page_Load(object sender, EventArgs e)


using AMAT.Web;
using AjaxControlToolkit;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Controls_ColorPicker {

protected TextBox TextBox1;

protected ColorPickerExtender ColorPickerExtender1;
1 person has
this question