Tuesday, September 22, 2015

asp.net update panel

1) Update Panel

<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSetRadEditorContent" EventName="Click" />
</Triggers>
<ContentTemplate>
<div style="float: left; width: 59%; margin-left: 10px; border: 1px solid #e2e6eb;">
<%--<iframe id="ifrmWrkDocViewer" src="#" style="height: 430px !important; width: 100%; margin-left: 5px;"></iframe>--%>
<telerik:RadEditor ID="RadEditor1" runat="server" ContentFilters="DefaultFilters, PdfExportFilter">
<ExportSettings FileName="RadEditorExport" OpenInNewWindow="true"></ExportSettings>
</telerik:RadEditor>
<asp:Button ID="btnSetRadEditorContent" runat="server" OnClick="btnSetRadEditorContent_Click" Style="display: none;" />
</div>
</ContentTemplate>
</asp:UpdatePanel>


2) Button click

protected void btnSetRadEditorContent_Click(object sender, EventArgs e)
{
string filePath = Server.MapPath("~/SampleInitialContent.docx");
byte[] fileBinaryData = File.ReadAllBytes(filePath);
string convertedContent = Functions.ConvertDocxToHtml(fileBinaryData);

RadEditor1.Content = convertedContent;
}


3) Javascript Function

 function SetDocumentEditorSrc(WrkID) {
                __doPostBack('<%= btnSetRadEditorContent.UniqueID %>');
            }


No comments:

Post a Comment