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

10 posts, 0 answers
  1. Taeho Yoo
    Taeho Yoo avatar
    11 posts
    Member since:
    Jun 2008

    Posted 06 Aug 2008 Link to this post

    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

  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 07 Aug 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Taeho Yoo
    Taeho Yoo avatar
    11 posts
    Member since:
    Jun 2008

    Posted 07 Aug 2008 Link to this post

    Thank you so much for your reply but could you give me some more information please? I don't really get it :(

    Thanks
  5. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 08 Aug 2008 Link to this post

    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.
  6. David
    David avatar
    1 posts
    Member since:
    Dec 2011

    Posted 16 Dec 2011 Link to this post

    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?
  7. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 21 Dec 2011 Link to this post

    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
  8. Vijay
    Vijay avatar
    5 posts
    Member since:
    Apr 2012

    Posted 22 Mar 2013 Link to this post

    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



  9. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 27 Mar 2013 Link to this post

    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.
  10. Adam
    Adam avatar
    4 posts
    Member since:
    Apr 2013

    Posted 01 May 2014 in reply to Marin Bratanov Link to this post

    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
  11. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 06 May 2014 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017