Table of Contents
- Getting Started
- EO.Pdf
- EO.Web
- Overview
- Installation & Deployement
- EO.Web ToolTip
- EO.Web Rating
- EO.Web Slider & RangeSlider
- EO.Web ListBox
- EO.Web ComboBox
- EO.Web Captcha
- EO.Web ASPX To PDF
- EO.Web Slide
- EO.Web Flyout
- EO.Web EditableLabel
- EO.Web ImageZoom
- EO.Web Floater
- EO.Web Downloader
- EO.Web ColorPicker
- EO.Web HTML Editor
- EO.Web File Explorer
- EO.Web SpellChecker
- EO.Web Grid
- EO.Web MaskedEdit
- EO.Web Splitter
- EO.Web Menu
- EO.Web Slide Menu
- EO.Web TabStrip
- EO.Web TreeView
- EO.Web Calendar
- EO.Web Callback
- EO.Web MultiPage
- EO.Web Dialog
- EO.Web AJAXUploader
- EO.Web ProgressBar - Free!
- EO.Web ToolBar - Free!
- EO.WebBrowser
- EO.Wpf
- Common Topics
- Reference
Advanced Features |
Overview
EO.Web Downloader supports dynamic contents generation. For example, you may require user to enter a few criteria in order to dynamically generates an excel report for the user to download; or require user to fill in a form in order to generates a .pdf file with the user filled in information for user to download.
Please follow these steps to dynamically generate download contents:
- Set the Downloader's DynamicContent to true;
- Create a new class that derives from DynamicDownloadContent class, override GenerateContent method. For example:
-
Handle the Downloader's Download event, inside the event
handler, call DynamicDownload method on the event argument,
passing in the type of class defined in step 2 as the first
argument and any additional arguments you may have (for your content generating
logic) as the second parameter. For example,
private void Downloader1_Download(object sender, EO.Web.DownloadEventArgs e) { //Pass whatever argument to your content generator NameValueCollection args = new NameValueCollection(); args["Text"] = TextBox1.Text; //Start a dynamic download. The first parameter is the //type of the content generator class. The second parameter //is whatever additional parameters you wish to pass to //your content generator e.DynamicDownload(typeof(ContentGenerator), args); }
-
Inside your GenerateContent method,
checks for the additional argument passed and calls
SetFileName
to set the download file name, then call
Write
method to dynamically generates the download content. For example,
protected override void GenerateContent() { //Set the download file name SetFileName("test.txt", -1); //Get the argument we passed in string s = Arguments["Text"]; //Generates download contents based on the file //For demonstration purpose, this code only writes //whatever we passed in. However a real life //scenario is most likely to be much complicated. //For example, you may need to run a query based //on the argument passed in and then generates the //download content based on the query result byte[] buffer = Encoding.ASCII.GetBytes(s); Write(buffer, 0, buffer.Length); }
private class ContentGenerator: EO.Web.DynamicDownloadContent { protected override void GenerateContent() { //your code to generates the download contents ...... } }