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

3 posts, 1 answers
  1. Dan Ehrmann
    Dan Ehrmann avatar
    165 posts
    Member since:
    Jul 2004

    Posted 12 Apr 2009 Link to this post

    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. Dan Ehrmann
    Dan Ehrmann avatar
    165 posts
    Member since:
    Jul 2004

    Posted 14 Apr 2009 Link to this post

    any ideas on this one?
  3. Answer
    Rumen avatar
    14011 posts

    Posted 15 Apr 2009 Link to this post

    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) 
                //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.

    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top