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

Load RTF content in jquery dialog from ASP.net Gridview

1 Answer 121 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Damon
Top achievements
Rank 1
Damon asked on 14 Dec 2010, 11:50 PM
I'm trying to load an RTF document that we retrieve from a database when a user clicks on an ImageButton on a row in a standard ASP.net gridview. The code seems to get called (RowCommand on server side) to load the RTF but when the dialog is displayed it is blank. It is as if the dialog has been loaded and the callback to load the RTF is ignored.

In ASPX page I have:

<!-- Model Definition Viewer -->
<div id="Viewer">
  <twu:RadEditor runat="server" ID="DefViewer" Enabled="false" EditModes="Design" BorderStyle="None" Skin="Office2007">
    <Content>
    </Content>
  </twu:RadEditor>
</div>
<asp:UpdatePanel ID="GridUpdatePanel" runat="server" ChildrenAsTriggers="False" 
                    UpdateMode="Conditional">
  <ContentTemplate>
    <asp:GridView ID="ModelList" runat="server" AutoGenerateColumns="False" AutoGenerateSelectButton="false"
                        AllowPaging="true" CssClass="GridView" Width="600px" HorizontalAlign="Center" HeaderStyle-Height="40px">
                        <Columns
                          <asp:TemplateField HeaderStyle-Width="20px">
                            <ItemTemplate>
                              <asp:ImageButton ID="InfoPopup" Width="15px" ToolTip="Click to display full model definition" Style="border: 0px"
                                               runat="server" ImageUrl="~/Images/definition.gif" CommandName="Definition" />
                            </ItemTemplate>
                          </asp:TemplateField>
                          <asp:BoundField DataField="ModelID" />
                                    <asp:TemplateField HeaderText="Model Name" SortExpression="Name" HeaderStyle-Width="350px">
                                        <ItemTemplate>
                                            <asp:LinkButton style="text-decoration:none" ID="ModelNameHyperLink" runat="server" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' Text='<%# Eval("ModelName") %>' Font-Bold="True"></asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="ProviderId" />
                          <asp:BoundField DataField="Provider" HeaderText="Provider" HeaderStyle-Width="290px"/>
                        </Columns>
                        <AlternatingRowStyle CssClass="GridAlternating" />
                        <RowStyle CssClass="rowStyle" />
                        <PagerSettings Mode="NumericFirstLast" />
                        <SelectedRowStyle BackColor="#66CCFF"  Font-Bold="true" ForeColor="Black"  />
                      </asp:GridView
                    </ContentTemplate>
                    <Triggers>
                      <asp:AsyncPostBackTrigger ControlID="ModelList" EventName="PageIndexChanged" />
                      <asp:AsyncPostBackTrigger ControlID="ModelList" EventName="SelectedIndexChanged" />
                      <asp:AsyncPostBackTrigger ControlID="ModelList" EventName="RowCommand" />
                    </Triggers>
                  </asp:UpdatePanel>

Code Behind contains:

Protected Sub OnRowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles ModelList.RowCommand
  
 Try
    Select Case e.CommandName
    Case "Definition"
                    Dim RowIndex As Integer = Integer.Parse(e.CommandArgument.ToString)
                    Dim ModelID As String = Me.ModelList.Rows(RowIndex).Cells(ModelListColumnEnum.ModelId).Text
                    Dim ProviderId As String = Me.ModelList.Rows(RowIndex).Cells(ModelListColumnEnum.ProviderId).Text
  
                    'Get the Definition for the specified model/provider and display it.
                                       Try
                        Dim ModelDefinition As String = String.Empty
                        Dim ErrorDetails As String = String.Empty
                        If JiatClient.GetModelDefinition(ProviderId, ModelID, ModelDefinition, ErrorDetails, Utilities.CurrentJIATUser(Session).UserID) Then
                            Me.DefViewer.LoadRtfContent(ModelDefinition)
                        Else
                            Me.DefViewer.Content = "Either this model doesn't have a definition or it could not be loaded."
                        End If
 ScriptManager.RegisterClientScriptBlock(Page, Me.GetType, "FileOpen", "openDialog('Viewer');", True)
                    Catch ex As System.Exception
                        ThrowErrorMessage(ex.Message)
                    Finally
                        'We do some cleanup in here
     
                    End Try

openDialog is javascript jquery code in a separate js file. The code all seems to work except that the radeditor comes up empty. My only thought is that it is because the radeditor is loaded when the page is loaded and on every postback. the only way I could probably get this to work is to check in page load and see if I have a hiddenfield or something set to the RTF. Any ideas? I'm sure people will need more information.

1 Answer, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 20 Dec 2010, 09:26 AM
Hi Damon,

We are familiar with a problem causing RadEditor to stop working when moving around the DOM with JavaScript, which might be the cause of the problem with the loading of the RTF. Could you please try calling RadEditor's client-side method onParentNodeChanged() at the end of the openDialog function and see if the problem still occurs?
function openDialog(divId)
{
    //.....
 
    var editor = $find("<% = DefViewer.ClientID %>");
    editor.OnParentNodeChanged();
}

 If so, could you please open a support ticket and provide a simple fully runnable project reproducing the problem so we can investigate it further?

Greetings,
Dobromir
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Editor
Asked by
Damon
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Share this question
or