I have used the Telerik RadEditor and the ExportToPdf method in C# but
when the PDF is downloaded it contains 0KB, but it contains data in the RadEditor content.
This is my code:
<telerik:RadEditor runat="server" ID="RadEditor1" SkinID="DefaultSetOfTools"
Height="515px" Visible="false" ContentFilters="DefaultFilters,PdfExportFilter">
<ExportSettings OpenInNewWindow="true" FileName="ErinLetter">
</ExportSettings>
<ImageManager ViewPaths="~/PDFbarcode" UploadPaths="~/PDFbarcode" DeletePaths="~/PDFbarcode"></ImageManager>
</telerik:RadEditor>
<br />
<div align="right">
<asp:Button ID="btnPdf" runat="server" CssClass="NFButton" Text="PDF" OnClick="btnPdf_Click" />
</div>
The content binds from the backend, for example:
<h2>Test RadEditor</h2>
but it returns 0KB.
Try setting the RadEditor's Visible property to true. I don't think export will work if it is false.
Also, compare your setup with the original here http://demos.telerik.com/aspnet-ajax/editor/examples/pdfexport/defaultcs.aspx and see what's the difference that breaks stuff.
Try to set the content inline in the declaration:
<telerik:RadEditor runat="server" ID="RadEditor1" SkinID="DefaultSetOfTools"
Height="515px" Visible="false" ContentFilters="DefaultFilters,PdfExportFilter">
<Content>
<h2>Test RadEditor</h2>
</Content>
<ExportSettings OpenInNewWindow="true" FileName="ErinLetter">
</ExportSettings>
<ImageManager ViewPaths="~/PDFbarcode" UploadPaths="~/PDFbarcode" DeletePaths="~/PDFbarcode"></ImageManager>
</telerik:RadEditor>
You can also hide the editor by wrapping it in a hidden
Related
Right now I have an application that is currently using PrinceXML to make PDFs in our application, but we would like to move towards using Telerik as a solution. The only problem I could foresee is that it expects all the rendering to be done on the markup prior to calling it. For example, a form might have some JavaScript on the page that needs to run when the page loads to fully layout the form correctly. If Telerik's component can't handle that (meaning the form has to be fully rendered server-side prior to) then that's going to be a problem. I'm having a hard time finding documentation on whether the Telerik Document Processing Library handles this.
Telerik offers another solution for client-side export, e.g.
<telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
<telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
<div class="demo-container size-medium">
<div class="buttonsContainer">
<telerik:RadButton RenderMode="Lightweight" runat="server" OnClientClicked="exportPDF" Text="Export page to PDF" AutoPostBack="false" UseSubmitBehavior="false"></telerik:RadButton>
<telerik:RadButton RenderMode="Lightweight" runat="server" OnClientClicked="exportImage" Text="Export page to Image" AutoPostBack="false" UseSubmitBehavior="false"></telerik:RadButton>
<telerik:RadButton RenderMode="Lightweight" runat="server" OnClientClicked="exportSVG" Text="Export page to SVG" AutoPostBack="false" UseSubmitBehavior="false"></telerik:RadButton>
</div>
<telerik:RadClientExportManager runat="server" ID="RadClientExportManager1">
</telerik:RadClientExportManager>
</div>
<script>
var $ = $telerik.$;
function exportPDF() {
$find('<%=RadClientExportManager1.ClientID%>').exportPDF($("#main"));
}
function exportImage() {
$find('<%=RadClientExportManager1.ClientID%>').exportImage($("#main"));
}
function exportSVG() {
$find('<%=RadClientExportManager1.ClientID%>').exportSVG($("#main"));
}
</script>
Please take a look at the following demos:
https://demos.telerik.com/aspnet-ajax/client-export-manager/functionality/export-whole-pages/defaultcs.aspx
https://demos.telerik.com/kendo-ui/pdf-export/index and https://demos.telerik.com/kendo-ui/pdf-export/page-layout
I have two drop down lists where one is inside an update panel and the other is outside.When the Index is changed on ddlFaculty the whole page is posted back instead of a partial for the contents in the update panel.
I have read in the ASP docs that sometime validation controls bog down update panels but im not too sure if that's the problem here.
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="ddlFaculty" CssClass="col-md-2 control-label">Faculty</asp:Label>
<div class="col-md-10">
<asp:DropDownList ID="ddlFaculty" EnableViewState="true" class="form-control" CausesValidation="false" runat="server" autopostback="true" aria-expanded="true" ValidationGroup="g4" OnSelectedIndexChanged="ddlFaculty_SelectedIndexChanged">
<asp:ListItem Value="null">Select Faculty</asp:ListItem>
<asp:ListItem Value="Arts">Faculty of Arts</asp:ListItem>
<asp:ListItem Value="Business">Faculty of Business</asp:ListItem>
<asp:ListItem Value="Health">Faculty of Health</asp:ListItem>
<asp:ListItem Value="Industries">Faculty of Service Industries</asp:ListItem>
<asp:ListItem Value="Trades">Faculty of Trades</asp:ListItem>
<asp:ListItem Value="Maori">Te Wananga Maori</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator runat="server" ControlToValidate="ddlFaculty" ValidationGroup="g4"
CssClass="text-danger" Display="Dynamic" ErrorMessage="The faculty field is required." />
</div>
</div>
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="ddlCourse" CssClass="col-md-2 control-label">Course</asp:Label>
<div class="col-md-10">
<asp:UpdatePanel runat="server" id="UpdatePanel1" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label runat="server" id="lblfaculty"></asp:Label>
<asp:DropDownList runat="server" CssClass="form-control" ID="ddlCourse" ValidationGroup="g7" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlFaculty" EventName="SelectedIndexChanged"/>
</Triggers>
</asp:UpdatePanel>
<asp:RequiredFieldValidator runat="server" ControlToValidate="ddlCourse" ValidationGroup="g7"
CssClass="text-danger" Display="Dynamic" ErrorMessage="The course field is required." />
</div>
</div>
Try using the AsyncPostBackTrigger property of the UpdatePanel.
See: How to stop UpdatePanel from causing whole page postback?
Did you try setting Button1 as an AsyncPostBackTrigger in the Triggers section, set the ChildrenAsTriggers property to true and the UpdateMode property to Conditional
Other solutions:
User control inside update panel causing full page postback
Full postback happens if your UpdatePanel cannot render its contents to a (e.g., when it is situated inside of ). So check you html inside of UpdatePanel, you might find the answer there (also, look for some incorrect xhtml, like incorrectly closed elements).
UpdatePanel causes full page postback
Unless you know of known issues that your site has when running in XHTML mode (and which you don't have time yet to fix), I'd always recommend removing the section from your web.config file (or you can explicitly set it to "Transitional" or "Strict").
This will make your HTML output standards compliant. Among other things, this will cause the HTML from your server controls to be "well formed" - meaning open and close tag elements always match. This is particularly important when you are using AJAX techniques to dynamically replace the contents of certain HTML elements on your page (otherwise the client-side JavaScript sometimes gets confused about container elements and can lead to errors). It will also ensure that ASP.NET AJAX works fine with your site.
It turns out that the page was infact sending a partial postback but I had mistaken the scroll to the top of the page when the postback had been recieved as a full page post back
i have a required fields in the 2nd and 3rd ajax accordion panels. i have the setfocus=true on my required field validator the the appropriate panel does not automatically open.
is there a way i can get it to open the panel, where the next required field is located?
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Accordion
ID="Accordion1"
runat="server">
<Panes >
<asp:AccordionPane runat="server" >
<Header>General Information </Header>
<content>
<asp:textbox id="textbox1" runat="server"/>
</content>
</asp:AccordionPane>
<asp:AccordionPane runat="server" >
<Header>Other Information </Header>
<content>
<asp:textbox id="textbox2" runat="server"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" SetFocusOnError="true" runat="server"
ErrorMessage="error on textbox 2" ControlToValidate="textbox2" ForeColor= "Red" ValidationGroup="main">*</asp:RequiredFieldValidator>
</content>
</asp:AccordionPane>
<asp:AccordionPane runat="server" >
<Header>More Information </Header>
<content>
<asp:textbox id="textbox3" runat="server"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" SetFocusOnError="true" runat="server"
ErrorMessage="error on textbox 3" ControlToValidate="textbox3" ForeColor= "Red" ValidationGroup="main">*</asp:RequiredFieldValidator>
</content>
</asp:AccordionPane>
</asp:accordion>
//the rest of the code here
//i typed this up, so please forgive if not everything is case sensitive
in this case, if i am on the first Pane, and click on the "validate" button, the required fields are in the second and third panes. the validation does fail, like it should, but the user is not taken to the textbox2 or textox3 (which are empty). how can i code it so that the focus is automatically set to the next failed textbox when the validation fails? it does work if i already have pane 2 open when i click on the "validate" button, in which case the focus is set to textbox2. but then again, if i put something in textbox2 and validate again, textbox3 fails, but the focus is not set.
hope this makes sense.
Its not strait forward to keep open two accordion panel at a time. Basically that control was not designed that way. You can use the collapsible panels instead.
But this article specifies a way to do that
http://www.c-sharpcorner.com/uploadfile/Zhenia/keeping-multiple-panes-open-in-accordion-web-control/
Also here are the link to open accordion panels using JavaScript.
http://forums.asp.net/t/1194270.aspx
jQuery Accordion - open specific section on pageload
Hope this helps
This is not just another FileUpload + UpdatePanel question.
I have, as stated in the many similar posts, an UpdatePanel and a FileUpload control on my form. I also have a PostBackTrigger set up for my upload button.
It works. The catch is it never does work on first time click. That is:
I click on browse, select my file, press upload. Nothing happens (fupld.HasFile = false);
I click on browse again, select any file (the same or another), press upload and it works fine.
<asp:UpdatePanel ID="upGeneral" runat="server" >
<ContentTemplate>
...
<table id="tabPage10" runat="server" visible="false" width="100%" >
<tr>
...
<td>
<asp:FileUpload ID="fupld" runat="server" Width="80%" />
<asp:ImageButton ID="ibtnUpld" runat="server" onclick="ibtnUpld_Click" />
<td>
...
<tr>
...
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="ibtnUpld" />
</Triggers>
</asp:UpdatePanel>
I've looked around for answers, but this is some really weird behaviour. No luck so far.
Any ideas?
Thanks
Well, the FileUpload control is designed to be used only in postback scenarios and not in asynchronous postback scenarios during partial-page rendering.
http://msdn.microsoft.com/en-us/ysf0192b#using_the_FileUpload_Control_with_the_UpdatePanel_control
You could use the AsyncFileUpload control instead from the AjaxControlToolkit.
<asp:AsyncFileUpload runat="server" ID="asyncFileUpload" Width="400px" ThrobberID="imageThrobber"
OnClientUploadStarted="uploadStarted" OnClientUploadError="uploadError"
ClientIDMode="AutoID" PersistFile="true" PersistedStoreType="Session" />
code behind:
if (asyncFileUpload.HasFile)
{
string fullPath = GetPath(asyncFileUpload.FileName);
asyncFileUpload.SaveAs(fullPath);
}
I've never had any problems with it.
With Post back triggers I had to use the below line of code in code behind:
Page.Form.Enctype = "multipart/form-data";
And this works perfectly fine.
Thanks to the solution in the link - (http://patelshailesh.com/index.php/file-upload-control-fails-first-time-then-works-on-subsequent-submits).
Change
Visible ="false"
to
style="display:none"
and change it from code behind.
If you set Visible="false, control is not actually rendered as HTML. To rendered it as HTML, use style = "display:none" instead of Visible="false"
Update:
There was actually a hidden panel with validator in the user control that was causing page not to be valid on the first postback. Consider this issue resolved.
This is first time I am using this control and it is behaving rather strange. I have to click on the "Next" button twice for it to move to the next step. I tried explicitly setting active index, using MoveTo etc. Nothing works. Here is the markup for the control. Anybody has any ideas why?
<asp:Wizard ID="UserWizard" runat="server" ActiveStepIndex="0"
StartNextButtonImageUrl = "~/App_Themes/Default/images/buttons/continue.gif" StartNextButtonType="Image"
StepNextButtonType="Image" StepNextButtonImageUrl="~/App_Themes/Default/images/buttons/continue.gif"
FinishPreviousButtonImageUrl="~/App_Themes/Default/images/buttons/back.gif"
FinishPreviousButtonType="Image" FinishCompleteButtonImageUrl="~/App_Themes/Default/images/buttons/save.gif"
FinishCompleteButtonType="Image" CancelButtonType="Image" CancelButtonImageUrl="~/App_Themes/Default/images/buttons/back.gif"
DisplaySideBar="false" >
<WizardSteps>
<asp:WizardStep Title="User Profile" ID="UserProfile" runat="server">
<uhc:ctlUserProfileEdit ID="ctlUserProfileEdit" runat="server">
</uhc:ctlUserProfileEdit>
<br clear="all" />
<div>
<asp:ImageButton ID="cmdResetPassword" runat="server" ImageUrl="~/App_Themes/Default/images/buttons/resetpassword.gif" />
</div>
<div>
<asp:UpdatePanel ID="upSchools" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<uhc:ctlSchoolLocationSelector ID="ctlSchoolLocationSelector" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:WizardStep>
<asp:WizardStep Title="Roles" ID="Roles" runat="server">
<uhc:ctlPermissionInternal ID="ctlPermissionInternal1" runat="server"></uhc:ctlPermissionInternal>
<uhc:ctlPermissionExternal ID="ctlPermissionExternal1" runat="server"></uhc:ctlPermissionExternal>
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
I don't know for sure if this is what's causing it, but I find it strange that there is an UpdatePanel within the Wizard control, rather than the Wizard Control within the update panel. This may be causing some strange behavior.
Can you change this and see if the problem resolves itself?