This is a migrated thread and some comments may be shown as answers.

Page cannot be null. Please ensure that this operation is being performed in the context of an ASP.NET request.

9 Answers 570 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Taeho Yoo
Top achievements
Rank 1
Taeho Yoo asked on 07 Aug 2008, 02:20 AM
Hi,

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

Sort by
0
Atanas Korchev
Telerik team
answered on 07 Aug 2008, 07:33 AM
Hi Taeho Yoo,

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.
0
Taeho Yoo
Top achievements
Rank 1
answered on 07 Aug 2008, 11:57 PM
Thank you so much for your reply but could you give me some more information please? I don't really get it :(

Thanks
0
Atanas Korchev
Telerik team
answered on 08 Aug 2008, 06:21 AM
Hi Taeho Yoo,

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.
0
David
Top achievements
Rank 1
answered on 16 Dec 2011, 05:33 PM
Is there any way to get the ColorPicker to render without a page?

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?
0
Marin Bratanov
Telerik team
answered on 21 Dec 2011, 12:34 PM
Hello David,

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
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Vijay
Top achievements
Rank 1
answered on 22 Mar 2013, 11:09 AM
Hello I'm using Telerik.Web.UI Telerik chart to generate images. 

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

This works ok from web and my unit tests, but when I access using windows service it fails? with 

throws object not initialised error stack trace points to save method. 

any help will be appreciated. 

ta



0
Ves
Telerik team
answered on 27 Mar 2013, 09:37 AM
Hi Vijay,

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
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Adam
Top achievements
Rank 1
answered on 01 May 2014, 09:50 PM
Marin,

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
0
Marin Bratanov
Telerik team
answered on 06 May 2014, 04:45 PM

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,

Marin Bratanov
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.

 
Tags
ComboBox
Asked by
Taeho Yoo
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Taeho Yoo
Top achievements
Rank 1
David
Top achievements
Rank 1
Marin Bratanov
Telerik team
Vijay
Top achievements
Rank 1
Ves
Telerik team
Adam
Top achievements
Rank 1
Share this question
or