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

[Solved] add html instead of update whole panel

7 Answers 172 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
goyaweb
Top achievements
Rank 2
goyaweb asked on 05 Jul 2007, 07:36 AM
I have a scenario where when I press a button an extra textbox needs to be shown. Everytime I click the button an extra textbox must be shown (so possibility to add unlimited textboxes). Unfortunately I can only add the textbox to a predefined updatepanel. Therefore everytime the whole panel gets sent over ajax line. How would I only send the html for 1 textbox and add that html to the page without refreshing the whole panel everytime?

7 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 05 Jul 2007, 07:43 AM
Hi goyaweb,

The MS AJAX and our own ajax framework preserve the page lifecycle and ViewState and therefore, you cannot achieve the desired functionality with ajax requests. In order to add dynamically controls to a control collection, you have to always update this control and it will always send the complete html of that control.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
goyaweb
Top achievements
Rank 2
answered on 05 Jul 2007, 09:24 AM
thanks for the reply.

Anybody a smart workaround for this?
0
Geoff Van Brunt
Top achievements
Rank 1
answered on 31 Jul 2007, 05:38 PM
Why don't you just add regular html textboxes (not controls) to the page on the client (without post or callback), name them something like (id="textbox1") etc then loop through them when posted or called back by using Request.Params?

In other words, is there some reason you have to post back to the server to "create" them?
0
goyaweb
Top achievements
Rank 2
answered on 12 Sep 2007, 12:54 PM
Hi Geoff,
Great point! People tend to use AJAX for the wrong thing I agree.
The reason I was using it is that the textboxes I was talking about are quite fancy textboxes, namely a combination of 2 DatePickers and 2 TimePickers. Is there a clientside API to add these Telerik controls using javascript?
Thanks,
Yannick
0
Sebastian
Telerik team
answered on 12 Sep 2007, 01:12 PM
Hi goyaweb,

Our date/time picker controls will preserve their lifecycle and viewstate only when added server-side following the conventions for dynamic controls creation in ASP.NET. Since our pickers are server controls, pure client-side instantiation is not possible as this will break some of their features/proper functioning (as the server will not be "aware" that new controls has been built on the client machine).

I hope this explanation makes sense.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Geoff Van Brunt
Top achievements
Rank 1
answered on 12 Sep 2007, 01:19 PM
As Steve mentioned in a previous post, it is currently not possible to create a server control on the client with ASP.Net 3.5 or earlier. This is due to ViewState, page validation etc. Perhaps MS will consider this down the road.

As for your problem, here is what I suggest. Use a RadWindow to pop up the complex control with all the date and time pickers etc. Then pass the values back to the main page and create regular textboxes there, but have them be uneditable. You can even add edit buttons beside them to open the RadWindow and edit them etc. If you use caching with the RadWindow you won't have ANY postbacks except for the first call to open the window.
0
jfs67
Top achievements
Rank 1
answered on 16 Sep 2007, 03:58 PM
This article by Jeff Prosise on MSDN might help you with some ideas. It was helpful for me:

http://msdn.microsoft.com/msdnmag/issues/07/06/WickedCode/
Tags
Ajax
Asked by
goyaweb
Top achievements
Rank 2
Answers by
Steve
Telerik team
goyaweb
Top achievements
Rank 2
Geoff Van Brunt
Top achievements
Rank 1
Sebastian
Telerik team
jfs67
Top achievements
Rank 1
Share this question
or