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:
Code Behind contains:
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.
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 TryopenDialog 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.