RadEditor add Value to Content via c#

3 Answers 153 Views
Editor UI for ASP.NET AJAX in ASP.NET MVC
NYO
Top achievements
Rank 2
Iron
NYO asked on 21 May 2021, 09:30 AM

Hi I am trying to add html table to the context via c#.

I am getting the value without the table.

Can anyone help me out .

StringBuilder sb = new StringBuilder();
               

                sb.Append(@"<table style='width: 100 %; '>");

                sb.Append(@"<tr>");
                for (int i = 0; i < 10; i++)
                {
                    sb.Append(@"<table style='width: 450px' > Val1 </ td > ");
                    sb.Append(@"<table style='width: 450px' > &nbsp;</ td >");
                    sb.Append(@"</tr>");
                    sb.Append(@"<tr>");

                    sb.Append(@"<table style='width: 450px' > Val2</ td > ");
                    sb.Append(@"<table style='width: 450px' > &nbsp;</ td > ");
                    sb.Append(@"</tr>");
                    sb.Append(@"<tr>");

                    sb.Append(@"<table style='width: 450px' > Val3 </ td > ");
                    sb.Append(@"<table style='width: 450px' > &nbsp;</ td > ");
                    sb.Append(@"</tr>");

                    sb.Append(@"<tr>");
                    sb.Append(@"<table style='width: 450px' > Val4 </ td > ");
                    sb.Append(@"<table style='width: 450px' > &nbsp;</ td > ");
                    sb.Append(@"</tr>");
                }

                sb.AppendLine(@"</ table >");

                RadEditor .Content= sb.ToString(); 

3 Answers, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 26 May 2021, 01:35 PM

Please find attached the requested sample.

Regards,
Rumen
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Rumen
Telerik team
answered on 21 May 2021, 03:32 PM

Hi,

You have one extra single quote at the end of the first line:

   sb.Append(@"<table style='width: 100 %; '>");

After I removed it along with the empty spaces in the td tags, I loaded the content in a standard textbox multiline element and this is what I get:


<table style='width: 100 %;><tr><table style='width: 450px'> Val1 </td> <table style='width: 450px'> &nbsp;</td></tr><tr><table style='width: 450px'> Val2</td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val3 </td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val4 </td> <table style='width: 450px'> &nbsp;</td> </tr><table style='width: 450px'> Val1 </td> <table style='width: 450px'> &nbsp;</td></tr><tr><table style='width: 450px'> Val2</td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val3 </td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val4 </td> <table style='width: 450px'> &nbsp;</td> </tr><table style='width: 450px'> Val1 </td> <table style='width: 450px'> &nbsp;</td></tr><tr><table style='width: 450px'> Val2</td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val3 </td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val4 </td> <table style='width: 450px'> &nbsp;</td> </tr><table style='width: 450px'> Val1 </td> <table style='width: 450px'> &nbsp;</td></tr><tr><table style='width: 450px'> Val2</td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val3 </td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val4 </td> <table style='width: 450px'> &nbsp;</td> </tr><table style='width: 450px'> Val1 </td> <table style='width: 450px'> &nbsp;</td></tr><tr><table style='width: 450px'> Val2</td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val3 </td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val4 </td> <table style='width: 450px'> &nbsp;</td> </tr><table style='width: 450px'> Val1 </td> <table style='width: 450px'> &nbsp;</td></tr><tr><table style='width: 450px'> Val2</td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val3 </td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val4 </td> <table style='width: 450px'> &nbsp;</td> </tr><table style='width: 450px'> Val1 </td> <table style='width: 450px'> &nbsp;</td></tr><tr><table style='width: 450px'> Val2</td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val3 </td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val4 </td> <table style='width: 450px'> &nbsp;</td> </tr><table style='width: 450px'> Val1 </td> <table style='width: 450px'> &nbsp;</td></tr><tr><table style='width: 450px'> Val2</td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val3 </td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val4 </td> <table style='width: 450px'> &nbsp;</td> </tr><table style='width: 450px'> Val1 </td> <table style='width: 450px'> &nbsp;</td></tr><tr><table style='width: 450px'> Val2</td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val3 </td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val4 </td> <table style='width: 450px'> &nbsp;</td> </tr><table style='width: 450px'> Val1 </td> <table style='width: 450px'> &nbsp;</td></tr><tr><table style='width: 450px'> Val2</td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val3 </td> <table style='width: 450px'> &nbsp;</td> </tr><tr><table style='width: 450px'> Val4 </td> <table style='width: 450px'> &nbsp;</td> </tr></ table >

Is this the content you'd like to load into RadEditor?

I loaded the sb.ToString();  string in a textarea and this was loaded in it as content.

 

Regards,
Rumen
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

NYO
Top achievements
Rank 2
Iron
commented on 26 May 2021, 06:56 AM

HI Rumen, thank you for your answer I do not see the extra quote mark. This Quote mark belongs to the style.
Rumen
Telerik team
commented on 26 May 2021, 07:12 AM

Hi NYO, you are correct for the single quote - there is no extra single quote because it is fine to be there to close the style!
Here is what is loading on my side with the provided content: 

   protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(@"<table style='width: 100 %;'>");

            sb.Append(@"<tr>");
            for (int i = 0; i < 10; i++)
            {
                sb.Append(@"<table style='width: 450px' > Val1 </ td > ");
                sb.Append(@"<table style='width: 450px' > &nbsp;</ td >");
                sb.Append(@"</tr>");
                sb.Append(@"<tr>");

                sb.Append(@"<table style='width: 450px' > Val2</ td > ");
                sb.Append(@"<table style='width: 450px' > &nbsp;</ td > ");
                sb.Append(@"</tr>");
                sb.Append(@"<tr>");

                sb.Append(@"<table style='width: 450px' > Val3 </ td > ");
                sb.Append(@"<table style='width: 450px' > &nbsp;</ td > ");
                sb.Append(@"</tr>");

                sb.Append(@"<tr>");
                sb.Append(@"<table style='width: 450px' > Val4 </ td > ");
                sb.Append(@"<table style='width: 450px' > &nbsp;</ td > ");
                sb.Append(@"</tr>");
            }

            sb.AppendLine(@"</ table >");

            RadEditor1.Content = sb.ToString();
        }

 

NYO
Top achievements
Rank 2
Iron
commented on 26 May 2021, 10:55 AM

Hi Rumen, there is still no table
0
NYO
Top achievements
Rank 2
Iron
answered on 26 May 2021, 10:54 AM | edited on 26 May 2021, 11:25 AM

Hi Rumen

I am trying to get the table like this.

 

Tags
Editor UI for ASP.NET AJAX in ASP.NET MVC
Asked by
NYO
Top achievements
Rank 2
Iron
Answers by
Rumen
Telerik team
NYO
Top achievements
Rank 2
Iron
Share this question
or