1

I have two webparts on a single page:

  1. Content Editor WebPart
  2. My Custom WebPart

I need to send content from 1 in HTML format to 2. Is there a way to achieve this?

I was thinking of, maybe, adding JavaScript to Content Link of CEWP that would read the content from the CEWP and store it somewhere temporarily and then parsing in with my custom WebPart.

Or is there a simpler way to read the data from CEWP? Please, help.

  • Can you please explain what does your custom web part need to do with the CEWP content ? – MdMazzotti Jan 13 '14 at 13:38
  • @MdMazzotti It is needed to generate the table of contents from the Content Editor HTML content. – Mariusz Ignatowicz Jan 13 '14 at 13:40
  • I'm not entirely sure I understand what you mean by "generate the table of contents from the Content Editor HTML content", but still see if my answer can be of any help – MdMazzotti Jan 13 '14 at 13:54
1

If you know the id than in your custom webpart you can do:

        ContentEditorWebPart cewp = (ContentEditorWebPart)Page.FindControl("controlID");
        string textFromCewp = cewp.Content.InnerText;

else if you dont know the id but only have one content editor webpart on that page than you could do:

        foreach (Control c in Page.Controls)
        {
            if (c is ContentEditorWebPart)
            {
                ContentEditorWebPart cewp = (ContentEditorWebPart)c;
                string textFromCewp = cewp.Content.InnerText;
            }
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.