I am creating a custom control in C#. this control will have a radcomboBox and lable in a html table. When you select an item in the radcomboBox, the selected item text will be diplayed in the lable. But when I try to render, I am getting error.
Page cannot be null. Please ensure that this operation is being performed in the context of an ASP.NET request.
RadComboBox
currencySelector = new RadComboBox();
currencySelector.ID = "dsfdsf";
//currencySelector.Items.Add(new Telerik.Web.UI.RadComboBoxItem("Australian"));
htmltableCell.Controls.Add(currencySelector);
htmlTableRow.Cells.Add(htmltableCell);
.....
currencyConverterTable.Rows.Add(htmlTableRow)
currencyConverterTable.RenderControl(output);
What am I doing wrong here???
Thanks,
Toby
9 Answers, 1 is accepted
You are not adding the combobox in the controls collection of the Page (or the controls collection of any other control already added to the Page).
Regards,
Albert
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Thanks
You need to add the currencyConverterTable to the controls collection of something already in the page e.g. the form:
Page.Form.Controls.Add(currencyConverterTable);
You can find additional info in this blog post.
Regards,
Albert
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

I had to add it in a situation where I write directly in the aspx, not aspx.cs.
Also, I might need to do it from a generic handler, ashx.
Is this possible?
The control needs to be added to a page, either in its markup, or in its code-behind. You could try the RenderControl method and write to Response.OutputStream, yet this is not a supported scenario and it success cannot be guaranteed, so I advise against such attempts.
Regards,
Marin
the Telerik team

radchart.Save throws object not initialised error
ScriptManager {"Page cannot be null. Please ensure that this operation is being performed in the context of an ASP.NET request."} System.InvalidOperationException
throws object not initialised error stack trace points to save method.
any help will be appreciated.
ta
Can you please provide more details about the problem? Here is what worked fine on my end. The code looks like this:
public
partial
class
Service1 : ServiceBase
{
public
Service1()
{
InitializeComponent();
}
protected
override
void
OnStart(
string
[] args)
{
RadChart chart =
new
RadChart();
chart.DataSource =
new
double
[] { 2, 3, 4, 5, 6 };
chart.DataBind();
chart.Save(@
"C:\test.png"
);
}
protected
override
void
OnStop()
{
}
}
And the project has references to System.Web and System.Web.Extensions assemblies (needed by RadChart). You can find the resulting file attached.
Best regards,
Ves
the Telerik team

Is there any way to accomplish what David is attempting to do, yet? We have a client that is wanting gauges in one of our Telerik.Reporting reports which we export to HTML. I would like to be able to create a placeholder in the report itself, then once the report was rendered, replace the placeholder with a gauge, server-side. Is that not possible with any products you offer? We're not using the report viewer, either - simply the ReportRenderer.
Thanks,
Adam
Hi Adam,
Could you confirm whether you need to embed data in an aspx page renderd in a browser, or are you generating a report? For the latter, perhaps the Telerik Reporting will be a more suitable tool rather than tampering with the rendered HTML from ASPX pages.
On the question whether an ASP.NET AJAX script control can render without a page, then be added somewhere (not to mention - continue functioning there) - this is not possible, nor will it be. IScriptControls require the server lifecycle of the webform page and a Scriptmanager to register their resources, then the MS AJAX client-side scripts to generate their $create() statements and instantiate their client-side objects, so they can work. This cannot happen without a page.
If you are looking for widgets that you can easily create dynamically - perhaps the JavaScript Kendo UI framework will be of interest, because it only needs its scripts in the browser, from this point on you can create HTML elements and instantiate widgets over them without going to the server.
Regards,
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.