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

Dynamically creating controls using web service

6 Answers 96 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Harry Kable
Top achievements
Rank 1
Harry Kable asked on 27 Apr 2010, 09:59 AM
Hi
I have been experimenting with creating standard input controls dynamically based on this external post http://weblogs.asp.net/sanjeevagarwal/archive/2008/07/22/Dynamically-create-ASP.NET-user-control-using-ASP.NET-Ajax-and-Web-Service.aspx
Basically, in my application, an AJAX call is made to a web service which dynamically creates a virtual page of controls (based on meta data from a database) and renders the page to an html string using HttpContext.Current.Server.Execute(page, textWriter, false). A callback function inserts the html into a div.  This is not a new concept but is new to me.
I have successfully implemented it for up to 1000 ASP.NET text boxes. However, when I add just 1 Telerik text box, an exception occurs when executing the command HttpContext.Current.Server.Execute(page, textWriter, false);. "Error executing child request handler. 'System.Web.Ui.Page'. 
I have researched other articles in this forum and extensively on the web but cannot find an answer.  I assume it is connected with the way in which Telerik controls are referenced in Visual Studio or by ASP.NET but I do not have the expertise to debug the issue. 
This is a focal issue for my application.
Can you please help.
Thanks and regards
Harry Kable 

6 Answers, 1 is accepted

Sort by
0
Dimitar Milushev
Telerik team
answered on 29 Apr 2010, 01:12 PM
Hello Harry,

For loading ASP.NET AJAX controls from a Web Service, we recommend using the XmlHttpPanel control that we provide.

Best wishes,
Dimitar Milushev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Harry Kable
Top achievements
Rank 1
answered on 29 Apr 2010, 11:45 PM
Hi Dimitar
Thanks for your reply. It sounds interesting. However, I have 2 questions:
1. How can I load standard Html elements together with Telerik controls?
2. Can I append additional Html and controls in successive client initiated calls?
Regards
Harry Kable
0
Dimitar Milushev
Telerik team
answered on 30 Apr 2010, 02:40 PM
Hi Harry,

I did some research about the error mentioned and it seems to be thrown when the Executed handler throws an exception. You can resolve this by setting RegisterWithScriptManager = false; to each RadControl that you are using.

Please excuse me for misleading you earlier.

Regards,
Dimitar Milushev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Harry Kable
Top achievements
Rank 1
answered on 01 May 2010, 12:15 AM
Hi Dimitar
Thank you for your help.
Your solution does indeed solve the problem and the methodology now works well.
Regards
Harry Kable
0
Harry Kable
Top achievements
Rank 1
answered on 04 May 2010, 01:24 AM
Hi Dimitar
There seems to be some issues with controls created dynamically in this way:
1. The client side events (OnValueChanged) does not fire;
2. The Type property for RadNumericTextBox is not honoured.
I am happy to change my methodology to use an XmlHttpPanel but I then need help with my earlier questions:
1. How can I load standard Html elements together with Telerik controls?
2. Can I append additional Html and controls in successive client initiated calls?
Thanks and regards
Harry Kable
0
Dimitar Milushev
Telerik team
answered on 06 May 2010, 02:17 PM
Hello Harry,

1. Client-side events are not fired because the control's Javascript is not evaluated (i.e. executed) by the browser.

2. I believe this is caused by the same issue.

The XmlHttpPanel can take care of evaluating the controls' Javascript in such scenarios.

As shown in the XmlHttpPanel example I linked, adding controls is as simple as adding any WebControl to the Panel's Controls collection, so you can add any of the "simple" HtmlControls or a LiteralControl with html markup.

The XmlHttpPanel replaces its content with each request so adding more content would require recreating the previous content plus adding the new one.

Greetings,
Dimitar Milushev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Ajax
Asked by
Harry Kable
Top achievements
Rank 1
Answers by
Dimitar Milushev
Telerik team
Harry Kable
Top achievements
Rank 1
Share this question
or