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

difficult to override RenderControl() methord with Telerik

2 Answers 75 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
wajira
Top achievements
Rank 1
wajira asked on 04 Aug 2009, 09:39 AM
I need to dynamically add some controlls to a web user control.
  
I'm putting all the controlls to a Table control and adding to the page as follows at the RenderControl event.

 

Public Overrides Sub RenderControl(ByVal writer As System.Web.UI.HtmlTextWriter)

 

 

Dim panel As New Panel

 

 

Dim outerTable As New Table

 

outerTable = generateDynamicControls()

panel.Controls.Add(outerTable)

panel.RenderControl(writer)

 

MyBase.RenderControl(writer)

 

 

End Sub

 


When I adding simple ASP controls to this outer table, it is working fine.
But when I add Telerik Controls gives following error when it execute  "panel.RenderControl(writer)" code.
Error:
Page cannot be null. Please ensure that this operation is being performed in the context of an ASP.NET request.

I'm using a Master page also.

Can u help me?

2 Answers, 1 is accepted

Sort by
0
Serban
Top achievements
Rank 1
answered on 10 Jul 2011, 10:18 AM
Did you ever get an answer for this?
0
Sebastian
Telerik team
answered on 11 Jul 2011, 09:53 AM
Hello guys,

Adding ASP.NET server controls on the RenderControl phase is too late in the control lifecycle, thus their viewstate will be corrupted and they will behave abnormality. You should generate those controls either When the Init/Load or the CreateChildControls event of the user control is raised.

Regards,
Sebastian
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
General Discussions
Asked by
wajira
Top achievements
Rank 1
Answers by
Serban
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or