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

Editor Issues On Page_Load Only

6 Answers 77 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 22 May 2009, 02:22 PM
I have an issue that I just cant seem to get correct, and I really do not understand why.

I have a page that loads some HTML from a SQL database and I want it displayed in the RadEditor control.  The idea is to load the record they have marked as default on the page load, and then have a ComboBox so they can switch from record to record.  The html that comes from the database doesn't have any header tags like "<html>" or "<header>", but it is well formed html with style and formatting tags like tables, paragraphs, etc...

 
<tr> 
                        <td align="right"
                            Message Template:</td> 
                        <td width="25" align="left"
                            &nbsp;</td> 
                        <td align="left"
                            <telerik:RadComboBox ID="list_templates" Runat="server" Skin="Sunset"  
                                AppendDataBoundItems="True" AutoPostBack="True" DataTextField="msg_title"  
                                DataValueField="id"  
                                OnSelectedIndexChanged="list_templates_SelectedIndexChanged"  
                                DataSourceID="sqlds_MsgTemplates"
                                <CollapseAnimation Duration="200" Type="OutQuint" /> 
                            </telerik:RadComboBox> 
                        </td> 
                    </tr> 
 <tr> 
                        <td align="right"
                            Message Subject:</td> 
                        <td> 
                            &nbsp;</td>
                        <td align="left"
                            <telerik:RadTextBox ID="txt_Sub" Runat="server" Skin="Sunset" Width="400px" Text=""
                            </telerik:RadTextBox> 
                        </td> 
                    </tr> 
                    <tr> 
                        <td colspan="3"><center> 
                            <telerik:RadEditor ID="editor_SEND" runat="server" BorderStyle="None"  
                                EditModes="Preview" Height="400px" Skin="Sunset"  
                                ToolsFile="UserControls/EditorToolbar.xml" Width="700px"
                                <Content> 
</Content> 
                            </telerik:RadEditor></center
                            <br /> 
                            <br /> 
                            <asp:Button ID="btn_SendMsg" runat="server" CssClass="RadDefaultButton"  
                                Text="Send Message" /> 
                        </td> 
                    </tr> 

On Page Load I want to get the record (which loads successfully) and display it in the control. However on page load when I do the following, the editor is empty and it is not in preview mode - the toolbar buttons are still luminated.
If Not IsPostBack Then 
 
Try 
 
                    Using reader As SqlDataReader = Msg_Info.GetDealerTemplateByID(CInt(Request.QueryString("Record"))) 
 
                        If reader.HasRows Then 
 
                            reader.Read() 
 
                            txt_Sub.Text = reader.GetSqlString(0).ToString() 
                            editor_SEND.Content = reader.GetSqlString(1).ToString() 
 
                        End If 
 
                        reader.Close() 
 
                    End Using 
 
                Catch ex As Exception 
                    'error 
                End Try 
 
End If 



But then when I do this - it works fine:
Protected Sub list_templates_SelectedIndexChanged(ByVal o As ObjectByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) 
 
Dim msgID As Integer = list_templates.SelectedValue 
 
Try 
 
                    Using reader As SqlDataReader = Msg_Info.GetDealerTemplateByID(msgID) 
 
                        If reader.HasRows Then 
 
                            reader.Read() 
 
                            txt_Sub.Text = reader.GetSqlString(0).ToString() 
                            editor_SEND.Content = reader.GetSqlString(1).ToString() 
 
                        End If 
 
                        reader.Close() 
 
                    End Using
 
                Catch ex As Exception 
 
                End Try 
 
    End Sub 

They are identical but why doesn't the page load display it properly?



6 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 25 May 2009, 02:46 PM
Hello Shawn,

I am unable to see anything wrong in your code and my suggestion is to replace the editor with a standard <asp:TextBox> control and see whether you should experience the same problem.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Shawn
Top achievements
Rank 1
answered on 26 May 2009, 05:38 PM
An asp:TextBox wont display my string in html though correct?

What is weird is the Editor works fine after I have a postback but on page load it doesn't load the html string in the content.  It also doesn't put it in preview mode like it is supposed to be until something else is called.  Should I be performing these try blocks somewhere other than the Page_Load event?
0
Tervel
Telerik team
answered on 29 May 2009, 01:05 PM
Hello Shawn,

One possibility is that your code never gets inside the If statement at page load - after all it depends on the existence of QueryString("Record") - which might be simply missing the first time you load the page.

We do not have your complete code, so this is simply a speculation.

In case you have a problem, the original suggestion is still valid - please make sure you are able to successfully load the content you need in a regular <asp:TextBox> - just for test purpose! The problem that you are having seems to be in the logic of your code, rather than in the editor - as you say that the same code, when executed in the
OnSelectedIndexChanged event works fine.

All the best,
Tervel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Chris
Top achievements
Rank 1
answered on 01 Jun 2009, 07:14 AM
I am having a similar problem. I am also loading HTML from SQL. I set the editor's Edit Mode to HTML.
It is also wired to a DropDownList. On the first post back I see nothing in the editor, although it tells me there are 24 words and 199 characters. Once I choose ANYTHING else from the dropdown, any subsequent postback shows the HTML properly in the radeditor. I can't see what the radeditor is doing differently beyond the initial page load. I am also trying to control the height of the radeditor so maybe that has something to do with it...

I will do more testing.

** Update: I have figured out my issue. I set EditModes="HTML" because I only want to show naked HTML in the editor.
This causes the editor to not only be blank on the first load, but also I cannot even click in the empty box and type.
Am I wrong in assuming that I can limit the edit mode to ONLY HTML?
It's possible that this is what Shawn is doing as well?

Chris
0
Shawn
Top achievements
Rank 1
answered on 01 Jun 2009, 09:48 PM
My problem seems to be slightly different.  I am not limiting the edit mode at all and on page load my editor is completely blank and I can not type in it at all.  When I perofrm any postback on my dropdown list it then populates correctly and allows me to edit and change the view.

There isn't anything different going on during the postback that isnt happening with the page_load.

Could it have anything at all to do with the fact that my editor is in a multipage using the RadTabStrip?
0
Rumen
Telerik team
answered on 04 Jun 2009, 03:39 PM
Hi guys,

We are not sure what is causing the problems on your side and we kindly invite you to open support tickets and send us sample working projects demonstrating the problems that you experience. Please, provide detailed step-by-step instructions on how to reproduce the problems on our side.

Kind regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Editor
Asked by
Shawn
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Shawn
Top achievements
Rank 1
Tervel
Telerik team
Chris
Top achievements
Rank 1
Share this question
or