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

Returning Radeditor value to calling Page

1 Answer 55 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Renee
Top achievements
Rank 1
Renee asked on 01 Oct 2010, 05:26 PM
I have an application that has multi-line text box.  When I press the Insert button, it opens a RadWindow with the Rad Editor.  I want save the database and send the text back to the page with the text box.

Main Page
  
<head runat="server">
    <title>Testing</title>
   <link href="StyleSheet1.css" rel="stylesheet" type="text/css" />
 <script type="text/javascript">
       
     function OnClientClose(radWindow1, args) {
         var arg = args.get_argument();
         var text = document.getElementById('txtConclusion');
         text.value = arg.result;
           
     }
     function openWin() {
         var oWnd = radopen("insertcomments.aspx", "RadWindow2");
     }
  
     </script>
  
  
  
  
</head>
<body>
    <form id="form1" runat="server">
    <div>
     <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        <Windows>
        <telerik:RadWindow ID="RadWindow1" runat="server" NavigateUrl="Webform3.aspx" 
            ReloadOnShow="True" Top="60px" onclientclose="OnClientClose">
                </telerik:RadWindow>
                <telerik:RadWindow ID="RadWindow2" runat="server" NavigateUrl="insertcomments.aspx" 
             ReloadOnShow="True" Top="60px" onclientclose="OnClientClose" Width="660" Height="500px">
                </telerik:RadWindow>
        </Windows>
        </telerik:RadWindowManager>
        <table >
            <tr valign="top">
                <td>
                    <table >
                    <thead>
                        <tr>
                            <th scope="col">Conclusion</th>
                        </tr>
                        </thead>
                        <tr>
                            <td>    
                                <asp:TextBox ID="txtConclusion" runat="server" Height="249px" 
    style="margin-bottom: 72px" TextMode="MultiLine" Width="138px" ReadOnly="True"></asp:TextBox>
                       <br /> 
                              <button onclick="openWin(); return false;">Insert</button>
  
                                          </td>
                        </tr>
                          
                    </table></td>
                <td>
                   <table class="section">
                    <thead>
                        <tr>
                            <th scope="col">Current News</th>
                        </tr>
                        </thead>
                        <tr>
                            <td><asp:TextBox ID="txtCurrentNews" runat="server" Height="160px" 
    style="margin-bottom: 72px" TextMode="MultiLine" Width="138px"></asp:TextBox>
                            </td>
                        </tr>
                    </table></td>
            </tr>
            <tr>
                <td>
                     </td>
                <td>
                     </td>
            </tr>
        </table>
    </div>
      
  
  
  
    </form>
</body>
</html>
  
Popup Page
Pop Page
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  
<head runat="server">
   <title>Investment Web Site</title>
   <link href="StyleSheet1.css" rel="stylesheet" type="text/css" />
     
   <script type="text/javascript">
         function GetRadWindow() {
             var oWindow = null;
             if (window.radWindow)
              oWindow = window.radWindow;
          else if (window.frameElement.radWindow)
              oWindow = window.frameElement.radWindow;
             return oWindow;
         }
       function CloseWindow() {
             var currentWindow = GetRadWindow();
             var oarg = new Object();
             oarg.result = document.getElementById("RadEditor1").content;
              //var result = document.getElementById("RadioButtonList1_0").checked;
             //currentWindow.argument = arg;
             currentWindow.Close(oarg);
         }
          
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
    </telerik:RadScriptManager>
          
        <br />
            <table style="width: 680px" cellspacing="3" cellpadding="5">
               <tr>
                   <td style="width: 100%"><asp:Image ID="imgTitle" runat="server" />
                   <p><asp:Label ID="lblMessage" runat="server" Visible = "false" CssClass ="red" ></asp:Label></p></td>
               </tr>
               <tr>
                   <td >
                       <telerik:RadEditor ID="RadEditor1" Runat="server" ToolsFile="~/BasicTools.xml" Width="600px">
                           <Content>
                          </Content>
                       </telerik:RadEditor>
                   </td>
               </tr>
               <tr>
                   <td style="width: 100%; margin-top: 6px;" align="center"></td>
               </tr>
          </table>
      <div style="margin-left: 450px"
                                            <asp:ImageButton ID="imgAddComment" runat="server" 
                                                ImageUrl="~/images/btnAddComment.gif" />
                                                </div>
      </div>
      
    </form>
</body>
</html>
  
  
Code Behind
  
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
          
    End Sub
  
        Protected Sub imgAddComment_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAddComment.Click
        Dim ReturnMsg As String = ""
  
        Try
            If RadEditor1.Content <> "" Then
                If LCase(RadEditor1.Content).EndsWith("<br />") Then
                    RadEditor1.Content = RadEditor1.Content.Substring(0, Len(RadEditor1.Content) - 6)
                End If
  
                'ReturnMsg = InvestSupProviders.InsertConclusionComment(Session("CompanyID"), "", Session("UserSession").ID_User, Now, RadEditor1.Content)
                ReturnMsg = InvestSupProviders.InsertConclusionComment(21, "", 5, Now, RadEditor1.Content)
  
                If ReturnMsg = "" Then
                    lblMessage.Text = "Message added"
                    lblMessage.Visible = True
                    'RadEditor1.Content = "  "
                Else
                    lblMessage.Text = ReturnMsg
                    lblMessage.Visible = True
                End If
            Else
                lblMessage.Text = "There is no Content"
                lblMessage.Visible = True
            End If
  
        Catch ex As Exception
            'Page_Error(ex, "Page_Load")
        End Try
    End Sub
End Class

1 Answer, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 05 Oct 2010, 09:29 AM
Hi Renee,

To get the content of the RadEditor using JavaScript you need to use its client-side object. To get reference to the RadEditor's client-side object you need to use the $find() method. To achieve the required functionality you need to modify the CloseWindow() function to the following:
function CloseWindow() {
      var currentWindow = GetRadWindow();
      var oarg = new Object();
      var editor = $find("<%=RadEditor1.ClientID%>");
      oarg.result = editor.get_html(true);
       //var result = document.getElementById("RadioButtonList1_0").checked;
      //currentWindow.argument = arg;
      currentWindow.Close(oarg);
  }

You can find more detailed information regarding the RadEditor's Client-Side API in the following article:
Getting familiar with Client-Side API

All the best,
Dobromir
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Editor
Asked by
Renee
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Share this question
or