Radspell for radeditors which are dynamically created on page

8 posts, 0 answers
  1. Ritika
    Ritika avatar
    6 posts
    Member since:
    Oct 2012

    Posted 14 Oct 2012 Link to this post

    Hi,

    I have a radeditor with id="RadEditor1" on the page and a dropdown of numbers from 1-10. If i select a number from the dropdown i get those many radeditors with id= " RadEditor2" on the page(repeater is used to generate dynamically). I am using the Radspell button which should check the spellings of RadEditor1 as well as all the dynamically generated RadEditor2. How Can i do that? I want to use it for both static and dynamic controls of the page. If i assign controlstocheck property of the RadEditor as RadEditor1 and RadEditor2, and when i click Radspell button, if there are no RadEditor2 on the page,  it throws an error.
  2. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 15 Oct 2012 Link to this post

    Hi,

    You should update the value of the ControlsToCheck property every time when a new RadEditor is inserted. This means that you should attach to the OnSelectedIndexChanged event of the dropdownlist control and update the value of the ControlsToCheck property in it.

    Greetings,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ritika
    Ritika avatar
    6 posts
    Member since:
    Oct 2012

    Posted 15 Oct 2012 Link to this post

     Hi,
    I have tried using like this but it doesnt spell check radeditor2. Can you please check this sample(i have just added sample code)
    and let me know. should i use client id of the radeditor controls and set isclientid property to true?

     <telerik:RadEditor runat="server" ID="RadEditor1" </telerik:RadEditor>
    <asp:DropDownList runat="server" ID="ddl" AutoPostBack="true"/>
      <asp:Repeater runat="server" ID="rpt"  OnItemDataBound="rptCases_DataBound">
                <ItemTemplate>
              <telerik:RadEditor runat="server" ID="RadEditor2" </telerik:RadEditor>
      </ItemTemplate>
            </asp:Repeater>

    <telerik:RadSpell runat="server" ID="radspell" ControlsToCheck="RadEditor1" />
           

     this.ddl.SelectedIndexChanged += (s, a) => ProcessConsultationCases()

    ProcessConsultationCases()
    {
    for (long i = 1; i <= ddl; i++)
                   editor.Add();
    this.Cases = editor;
    }

    void rptCases_DataBound(object source, RepeaterItemEventArgs e)
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    var description=(RadEditor)e.Item.FindControl("RadEditor2");
                    this.radspell.ControlToCheck = "description";
                 }
            } 

    list<> Cases
            {
              set
                {
                    if (value.Count > 0 && value!=null)
                    {
                        this.rpt.Visible = true;
                        this.rpt.DataSource = value;
                        this.rpt.DataBind();
                    }
                    else
                        this.rpt.Visible = false;
                }
            }       
  5. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 18 Oct 2012 Link to this post

    Hi,

    You should fix your code because on this line you get a reference to RadEditor

    var description=(RadEditor)e.Item.FindControl("RadEditor2");

    and on the next one you set a string description
                    this.radspell.ControlToCheck = "description";

    but not

    this.radspell.ControlToCheck = description.ClientID;

    or

    this.radspell.ControlToCheck = description.ID;

    All the best,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Ritika
    Ritika avatar
    6 posts
    Member since:
    Oct 2012

    Posted 23 Oct 2012 Link to this post

    Hi,

    I did that..
    var description=(RadEditor)e.Item.FindControl("RadEditor2");
    this.radspell.ControlToCheck = "description";

     It does not spell check RadEditor2/description, it does only spellcheck for RadEditor1.

  7. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 26 Oct 2012 Link to this post

    Hi,

    Please, read my earlier post once again.

    You should pass the ID of RadEditor to the ControlsToCheck property but not the string "description"; as you have set this.radspell.ControlToCheck = "description";, because you do not have such an editor with ID description on the page.

    You should set

    var description=(RadEditor)e.Item.FindControl("RadEditor2");
    this.radspell.ControlToCheck = description.ClientID;

    or

    var description=(RadEditor)e.Item.FindControl("RadEditor2");
    this.radspell.ControlToCheck = description.ID;

    and test.

    You can find an example with the ControlsToCheck property set in the codebehind in the following live demo: Overview.

    Kind regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  8. Ritika
    Ritika avatar
    6 posts
    Member since:
    Oct 2012

    Posted 28 Oct 2012 Link to this post

    Hi,

    I have tried using it in the below ways, it does not work still. it only spellchecks radeditor1.

    <telerik:RadSpell runat="server" ID="radspell" ControlsToCheck="RadEditor1" />

    var description=(RadEditor)e.Item.FindControl("RadEditor2");
    this.radspell.ControlToCheck = description.ClientID;

    or 

    var description=(RadEditor)e.Item.FindControl("RadEditor2");
    this.radspell.ControlToCheck = description.ID;


    Is there any mistake again?
  9. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 31 Oct 2012 Link to this post

    Hello,

    You should do something like this on the server, once the new editor is created:

    string[] elementsToCheck = {RadEditor1.ClientID, RadEditor2.ClientID};
    radspell.ControlsToCheck = elementsToCheck;

    If you unable to solve the issue, open a support ticket and provide a simple fully working project for examination.

    Kind regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017