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

Multiple controls with the same ID 'dialogOpener'...

2 Answers 88 Views
Spell
This is a migrated thread and some comments may be shown as answers.
Dan Ehrmann
Top achievements
Rank 1
Dan Ehrmann asked on 12 Apr 2009, 03:20 PM
I am working on converting my old-style RadSpell to the new ajax version. I have the RadSpell control wrapped in my own class so I can set a few common properties and make updates a little easier. The wrapper looks like this:

public class SpellChecker : RadSpell {
 public SpellChecker() {
  this.Skin = "Default";
  this.ButtonType = Telerik.Web.UI.ButtonType.ImageButton;
 }
}

Nothing fancy. This worked fine with the old version, but with the ajax version I get the error message in the subject on a page that has two spell check controls (pages with a single control are fine). I changed the affected page to use the <telerik:RadSpell... /> tag instead of my own tag (bypassing the wrapper) and it worked correctly. So I wonder if there is some problem with the wrapper class concept, or if I need to set some property, or what.

2 Answers, 1 is accepted

Sort by
0
Dan Ehrmann
Top achievements
Rank 1
answered on 14 Apr 2009, 04:54 PM
...ping...

any ideas on this one?
0
Accepted
Rumen
Telerik team
answered on 15 Apr 2009, 08:13 AM
Hi Dan,

The problem is that you are setting some of the spell properties in the custom control's constructor code. This forces the spell to create its child controls too early - before it has its ID attribute set. This is why the child controls of the two spell checkers on the page end up with identical IDs and cause the server exception. You can fix this by setting the spell properties a bit later - for example, by overriding the OnInit event:

    public class ccSpeller : Telerik.Web.UI.RadSpell 
    { 
        protected override void OnInit(EventArgs e) 
        { 
            base.OnInit(e); 
            //Gets the Session object so we can use it in this class, otherwise it's inaccessible    
            System.Web.SessionState.HttpSessionState localSession = HttpContext.Current.Session; 
 
            //Look and Feel settings 
            this.ButtonType = Telerik.Web.UI.ButtonType.LinkButton; 
            this.CssClass = "SmallText"
            this.Language = "en-US"
 
            // Allows each user to have their own custom dictionary, so they can add their own  
            // words to it without affecting other users. 
            //this.CustomDictionarySuffix = "-userOID" + localSession["UserOID"].ToString(); 
            this.AllowAddCustom = false
        } 
    } 

I hope this helps.


Greetings,
Rumen
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Spell
Asked by
Dan Ehrmann
Top achievements
Rank 1
Answers by
Dan Ehrmann
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or