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

Saving formatting done by JavaScript : Surviving Postbacks & Form Decorator

3 Answers 28 Views
FormDecorator
This is a migrated thread and some comments may be shown as answers.
Aarsh
Top achievements
Rank 1
Aarsh asked on 15 Feb 2013, 03:51 AM

Hello,

I am having a simple requirement, I have JavaScript function to detect if a control is 'changed' (I am using telerik and .net controls). Where as I am 'binding' the JavaScript function on runtime to all controls (attributes.add for .net controls and setting the properties for the telerik controls)

Now this function does work as expected ... until a post-back. As we know, we are going to loose our changes after post-back, So I just wanted to know if there is a way where ...

  • I can actually dump all those formatting attributes to some literal and can later iterate thru them and 're-apply' ?
  • Or is there a way to do partial post-back for just that control so that I do not loose my changes ?
  • Or any other way , you may think of ...

I am emphasising more on getting it done rather emphasising on getting in done correctly. I have had given a thought to add a custom attribute or so, but again I am afraid that I might loose them as soon as the page makes a trip for post-back.

I did spend few hours doing some research but most scenarios yield using hidden variables, I am not feeling it useful for my purpose explained above, but you can correct me.

Another problem was for asp:DropDownList ... I applied styles using JavaScript and nothing happened, I disabled the form decorator and styles were applies properly as expected

3 Answers, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 19 Feb 2013, 12:41 PM
Hi Aarsh,

Without having enough information about the mentioned JavaScript function and your scenario it is hard to give you a suggestion. Storing information (e.g about the formatting attributes) in a hidden field is usually a viable solution, so you can use it. Another approach could be to do the storing directly in the ViewState of your page, however this is up to you and your actual scenario (i.e. if you have the data in the code-behind). Once the Q1 2013 release is out you could give the new persistence framwork a look to ease storing of custom attributes.

Regarding the decoration of the ASP DropDownList, what RadFormDecorator does initially is to hide it and then create its own DOM elements, so that the DropDownList looks decorated:
  • The header of the dropdown is visualized inside a span, wrapped in a link tag
  • The expanded dropdown is visualized inside an unordered list, wrapped inside a div tag.

You can find the full list of the CSS classes that RadFormDecorator uses for the decoration here.

This means that directly formatting a decorated select is not possible. If you need to modify your selects you can skip them by setting ControlsToSkip="Select" for the decorator.

On using AJAX - you can use AJAX to avoid disposing the entire page, but if a control that you have just modified is a part of the partial update it will still lose the custom styling, as this is how MS AJAX works. Another option you have is to use hidden panels to do the update so you can get the data to the client, then parse them through JavaScript, so the entire process is hidden away from the end user. There are numerous other ways on returning data like this (e.g. Page methods).

All the best,
Danail Vasilev
the Telerik team
Explore the entire set of ASP.NET AJAX controls we offer here and browse the myriad online demos to learn more about the components and the features they incorporate.
0
Aarsh
Top achievements
Rank 1
answered on 20 Feb 2013, 04:20 AM
Hi Danail, I really appreciate your response.

2013 release : Yes, I am excited to have somethiing like "data-"  from Microsoft, in my rad Controls by telerik, too

Yes it slipped out of my mind that asp:DD is no more asp:DD after radFormDecorator.


It is okay, if the control which is posting back looses styling as I can always reply them from server side too. So can you please share a demo application or code snippet to do so with telerik ? I will really appreciate if you would please help me to get the partial page updates going.

Thanking you in anticipation,
-Aarsh
0
Danail Vasilev
Telerik team
answered on 22 Feb 2013, 03:11 PM
Hello Aarsh,

I am glad to hear that you are excited about the new features of RadControls. The release of Q 2013 is on its way. You might find interesting the What’s New, Release History & Roadmap article as well as the What's New in Telerik Q1 2013 video.

Regarding the partial page updating you can ajaxify your controls with RadControls either by putting them inside RadAjaxPanel or by using RadAjaxManager. You can find online examples on how to do that here and here.

Kind regards,
Danail Vasilev
the Telerik team
Explore the entire set of ASP.NET AJAX controls we offer here and browse the myriad online demos to learn more about the components and the features they incorporate.
Tags
FormDecorator
Asked by
Aarsh
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Aarsh
Top achievements
Rank 1
Share this question
or