Hi!
At the moment, I'm trying to create a custom 'asp.net server control' (a .CS!! not an ASCX!!), which should contain some DevExpress asp.net controls. As a simple example, I'm just trying to render a ASPxTextbox within my custom control.
When being rendered, I get the following javascript error :
"Microsoft JScript runtime error: 'ASPxClientTextBox' is undefined"
So, I guessed some initialitation scripts are missing. Then I tried to including this base script by calling :
ASPxTextBox.RegisterBaseScript(this.Page);
This however did not work; the same javascript error still occurs.
The full code if my simple example custom control can be found below:
-------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web.ASPxCallback;
using DevExpress.Web.ASPxPopupControl;
using DevExpress.Web.ASPxGridView;
using System.Drawing;
using System.Web.UI.HtmlControls;
using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxClasses;
namespace TypeSelector
{
[DefaultProperty("OutputType")]
[ToolboxData("<{0}:TypeSelector runat=server></{0}:TypeSelector>")]
public class TypeSelector : WebControl
{
private ASPxTextBox textboxResult = new ASPxTextBox();
#region Public properties
public string OutputType
{
get
{
String s = (String)ViewState["OutputType"];
return s;
}
set
{
ViewState["OutputType"] = value;
}
}
#endregion
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
ASPxTextBox.RegisterBaseScript(this.Page);
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
//textbox
textboxResult.ID = this.ID + "TextboxResult";
textboxResult.Font.Size = FontUnit.XXSmall;
textboxResult.ReadOnly = true;
textboxResult.Width = Unit.Pixel(170);
}
protected override void RenderContents(HtmlTextWriter output)
{
output.Write(OutputType);
textboxResult.RenderControl(output);
}
}
}