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

Resource for dynamically created controls?

14 Answers 106 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lenny_shp
Top achievements
Rank 2
Lenny_shp asked on 16 Jun 2009, 02:30 PM
I looked up the web and there are plenty of issues/workarounds with handling the viewstates for dynamically created controls and statically designed elements.   However they are more like hacks and I'd prefer to avoid going to that route.

What is the best approach and gotchas if I need to create RadEditor, RadCombo, RadTextbox dynamically?

My page would have some static elements on the top and bottom of the page, and the center of the page would have some dynamically created controls based on what the user has selected from a dropdown.

It will have a RadUpload statically created and a button to validate during postback.
After postback if validation fails, the values the user entered in the dynamically created controls (RadTextbox/Combo/Editor) should remain.

I don't see VS2010 to mention any additional feature to the dynamically created control's viewstate issue.

14 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 18 Jun 2009, 11:01 AM
Hello Leonid,

There isn't anything specific to RadControls when adding them dynamically to a page. You should follow the same techniques as with regular asp.net server controls. Here is a couple of helpfl articles you can use for reference:

Adding Controls to a Web Forms Page Programmatically
http://msdn.microsoft.com/en-us/library/kyt0fzt1(VS.71).aspx

Retaining State for Dynamically Created Controls in ASP.NET applications
http://www.codeproject.com/KB/viewstate/retainingstate.aspx



Greetings,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Marbry
Top achievements
Rank 1
answered on 29 Sep 2011, 06:36 PM
What about the
<link href="/WebResource.axd?d=qi1WJ5tD....." type="text/css" rel="stylesheet" class="Telerik_stylesheet" />
links that it generates automatically for the styles in the header?  They aren't there on the page where I'm dynamically generating the Telelrik controls.

I can get that to work by just extracting those from another page and sticking them in the header though.  But do I need to worry about those changing when it's deployed, or are the parameters static, based on the version of the suite?
0
Peter
Telerik team
answered on 04 Oct 2011, 10:00 AM
Hi Marbry,

You can consider using Telerik CDN. Here is a help topic for more information - http://www.telerik.com/help/aspnet-ajax/radscriptmanager-cdn-support.html.

All the best, Peter
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
Marbry
Top achievements
Rank 1
answered on 04 Oct 2011, 02:12 PM
Considering that this is an intranet application that may not be the best solution.
0
Peter
Telerik team
answered on 06 Oct 2011, 03:38 PM
Hi Marbry,

By default the embedded skin styles will be served by the Telerik.Web.UI.Skins.dll assembly so you don't have to worry about registering them manually. Here is a help topic for more information -
http://www.telerik.com/help/aspnet-ajax/introduction-controlling-appearance-overview.html

Kind regards, Peter
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
Marbry
Top achievements
Rank 1
answered on 06 Oct 2011, 04:15 PM
Yes, on the original page it will.  But I'm essentially doing a scrape to extract the content and include it as part of another page.  If I don't add those manually to the 2nd page the controls won't be rendered correctly.
0
Simon
Telerik team
answered on 11 Oct 2011, 10:54 AM
Hi Marbry,

We do not support creating RadControls dynamically on the client-side. As far as I understand you have already created your controls and you are only missing their styles. Is this correct?

The URL of the link you are referring to depends on the web resource name, the name of the assembly and the last build date of the assembly. The first two will unlikely change, however, after the next Telerik.Web.UI upgrade the last argument will change. So your hard-coded link will be invalid.

In order to avoid this, you could register the required CSS files for the controls manually. Here is a help topic describing how you can do that.

I hope this helps.

Greetings,
Simon
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
Marbry
Top achievements
Rank 1
answered on 17 Oct 2011, 05:32 PM
That's right, the controls are created on the server side, but I'm extracting the content from that page and inserting it as a sub section on another page.

I have this working, I'm just extracting the contents of the header as well and appending that to the header in the target page.
0
Simon
Telerik team
answered on 23 Oct 2011, 05:11 PM
Hello Marbry,

I'm still not sure what is the problem you are currently experiencing, so I don't know what to further suggest to you as a solution.

Can you plaese confirm/deny the following:
  • You managed to get the controls working by extracting their contents from one page and moving them in another on the client side;
  • Only the styles cannot load in the above situation.
If the above are true, you can register the required CSS files for the controls manually. Here is a help topic describing how you can do that.

Greetings,
Simon
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
Marbry
Top achievements
Rank 1
answered on 24 Oct 2011, 01:58 PM
Yes it's working, no I'm not doing it on the client side.

So PageA is the page that I want to incorporate the content in, and PageB is the page that has the controls on it.  I make a WebRequest from PageA for PageB.  Then I load the result from that into an HTML document and extract the content from PageB that I want (including the header) and add it to PageA.
0
Simon
Telerik team
answered on 27 Oct 2011, 10:47 AM
Hi Marbry,

Thank you for the clarification.

So, what remains are the styles, is this correct? If so, I suggest you resort to manually registering the CSS links to PageB, so that they get transferred to PageA.

Please let me know if I am missing something.

Greetings,
Simon
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
Marbry
Top achievements
Rank 1
answered on 27 Oct 2011, 01:58 PM
It's working, I don't need to manually register anything.  The header content, which includes whatever is generated by the controls is copied from PageB to PageA along with the portion of the body content that I'm interested in.
0
Simon
Telerik team
answered on 01 Nov 2011, 11:46 AM
Hi Marbry,

In this case, can you please let me know if there is anything else that you have difficulties achieving or we can consider this case closed? 

Regards,
Simon
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
Marbry
Top achievements
Rank 1
answered on 01 Nov 2011, 01:54 PM
I don't need anything else regarding this particular subject.

Thank you.
Tags
General Discussions
Asked by
Lenny_shp
Top achievements
Rank 2
Answers by
Peter
Telerik team
Marbry
Top achievements
Rank 1
Simon
Telerik team
Share this question
or