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

Setting ToolProviderId property programmatically

2 Answers 42 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Joseph Alfano
Top achievements
Rank 1
Joseph Alfano asked on 04 May 2010, 03:57 PM
I am using the RadEditor control.  The RadEditor is wrapped into a user (ascx) control, and then multiple instances of this user control are being used on a web forms (aspx) page.  

I would like to use the ToolProviderID property so that all instances of the RadEditor use the same tools markup and script.  However, the RadEditor instances are in different naming containers, so I cannot simply use the ID property of the RadEditor.  From a post on your forum (http://www.telerik.com/community/forums/aspnet-ajax/editor/use-toolproviderid-when-radeditor-in-itemtemplate.aspx) I should be able to use the ClientId property of the first RadEditor control as the ToolProviderId value for all of the subseqent rad editors.

I would like to set the ToolPRoviderId property of the RadEditor controls programmatically.  My question to you is how early in the ASP.Net eventing pipeline do I have to set this property so that the markup and scripts will be correctly injected into the page?  

I find that if I set these properties in the PageLoad event of the containing web forms page via data binding, the ToolProviderId behavior is not correct, since excessive script and markup are inserted into the page.  If I set this propery in the OnInit event of the radEditor in the user control (the earliest I can do it in the user control), then everything works fine.

Do you have any guidance of how early in the ASP.Net event pipeline I need to set the ToolProviderId for it to work properly?

Thanks for the help!

2 Answers, 1 is accepted

Sort by
0
Lini
Telerik team
answered on 07 May 2010, 11:22 AM
Hello,

The ToolProviderID needs to be set before the editor creates its child controls - if it is not set by then, the editor will output more markup than needed because of the extra child controls. I looked at the editor code and saw that the child controls are created in the OnInit event, so from that code it seems that you cannot set the ToolProviderID later than OnInit.

However, you can use a small trick to set the provider later in the lifecycle. The actual value of the ToolProviderID is needed late in the control lifecycle (after PreRender). Before that we only check if a value is set or not. What you can do is set the value to something (e.g. "toBeChanged") in the OnInit event so the editor knows not to create additional controls and then set the actual client ID when you know it in the Load event.

All the best,
Lini
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
Joseph Alfano
Top achievements
Rank 1
answered on 07 May 2010, 02:56 PM
Great, Lini.  Thanks so much for looking into this!  Your information is very helpful.

Joe
Tags
Editor
Asked by
Joseph Alfano
Top achievements
Rank 1
Answers by
Lini
Telerik team
Joseph Alfano
Top achievements
Rank 1
Share this question
or