|
Rank: Member Groups: Member
Joined: 12/9/2010 Posts: 28
|
When using a Downloader, I am receiving a JavaScript error:
Code: JavaScript
unable to get value of the property 'eo_l': object is null or unidentified
I have a Grid displaying available files, and a Downloader control, both wrapped in a CallbackPanel. All of the elements are wrapped in a user control. While the downloader does appear to work, the error is appearing (depending on the user's browser settings: I keep mine to show JavaScript errors) When debugging, this is shown:
Code: C#
Unhandled exception at line 6, column 31641 in http://localhost:60468/eo_web.ashx?id=b8c5bf7a-9b2d-40d1-9968-dd5a545d867c
0x800a138f - Microsoft JScript runtime error: Unable to get value of the property 'eo_l': object is null or undefined
What should I be looking at to set the eo_l property?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
Can you post a test page that we can use the duplicate the error here?
Thanks!
|
|
Rank: Member Groups: Member
Joined: 12/9/2010 Posts: 28
|
Working on a simple case now.
|
|
Rank: Member Groups: Member
Joined: 12/9/2010 Posts: 28
|
I have found the specific point at which it fails (within the Dynamic Download class, the point where it is obtaining the argument by index)
Code: HTML/ASPX
<eo:Downloader runat="server" id="Downloader1" DownloadButtonID="Button1" DirectLinkLabelID="Label1"
DynamicContent="True" OnDownload="Downloader1_Download" AutoHideDownloadButton="False" CausesValidation="False"></eo:Downloader>
<asp:Button Runat="server" ID="Button1" Text="Download Selected"></asp:Button>
Code: C#
...
protected void Downloader1_Download(object sender, EO.Web.DownloadEventArgs e)
{
DownloadSelected(e);
}
private void DownloadSelected(EO.Web.DownloadEventArgs e)
{
int gridSelectedItemIndex = Grid1.SelectedItemIndex;
GridItem item = Grid1.Items[gridSelectedItemIndex];
string key = item.Key.ToString();
Guid id = Guid.Empty;
if (Guid.TryParse(key, out(id)) && id != Guid.Empty)
{
NameValueCollection args = new NameValueCollection();
args["Key"] = key;
e.DynamicDownload(typeof(DynamicDownload), args);
}
}
...
public class DynamicDownload : EO.Web.DynamicDownloadContent
{
protected override void GenerateContent()
{
Document content = null;
String key = string.Empty;
// get args
try
{
[color=red] key = this.Arguments["Key"]; [/color]
Guid ID = Guid.Empty;
if (Guid.TryParse(key, out ID) && ID != Guid.Empty)
{
using (Repository repository = new Repository())
{
content = new Document(repository.GetDocument(ID));
}
}
}
catch
{ }
int contentLength = content.Content.Length;
SetFileName(content.FileName, contentLength);
byte[] buffer = content.Content;
Write(buffer, 0, buffer.Length);
}
}
|
|
Rank: Member Groups: Member
Joined: 12/9/2010 Posts: 28
|
This does *not* seem to happen when AutoHideDownloadButton="True"
Code: HTML/ASPX
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EOWebTestProject._Default" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
<asp:Content runat="server" ID="FeaturedContent" ContentPlaceHolderID="FeaturedContent">
<section class="featured">
<div class="content-wrapper">
<hgroup class="title">
<h1><%: Title %>.</h1>
<h2>Modify this template to jump-start your ASP.NET application.</h2>
</hgroup>
<p>
To learn more about ASP.NET, visit <a href="http://asp.net" title="ASP.NET Website">http://asp.net</a>.
The page features <mark>videos, tutorials, and samples</mark> to help you get the most from ASP.NET.
If you have any questions about ASP.NET visit
<a href="http://forums.asp.net/18.aspx" title="ASP.NET Forum">our forums</a>.
</p>
</div>
</section>
</asp:Content>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<p>
EO.Web Downloader can generate dynamic download content on the fly. The
following sample demonstrates this feature. You can enter a line count number
and the downloader will dynamically generates a text file with that number of
lines for download.
</p>
<p>
See remarks section for more details about how to use this feature.
</p>
<eo:CallbackPanel ID="CallbackPanel1" runat="server" Height="150px" Width="200px" Triggers="{ControlID:Downloader1;Parameter:},{ControlID:Button1;Parameter:}">
Enter Line Count:
<asp:TextBox Runat="server" ID="TextBox1"></asp:TextBox>
<p>
<eo:Downloader runat="server" id="Downloader1" DownloadButtonID="Button1" DirectLinkLabelID="Label1"
DynamicContent="True" AutoHideDownloadButton="False" OnDownload="Downloader1_Download"></eo:Downloader>
<asp:Label Runat="server" ID="Label1"></asp:Label>
</p>
<asp:Button Runat="server" ID="Button1" Text="Generate File & Download"></asp:Button>
</eo:CallbackPanel>
</asp:Content>
Code: C#
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace EOWebTestProject
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Downloader1_Download(object sender, EO.Web.DownloadEventArgs e)
{
NameValueCollection args = new NameValueCollection();
string key = Guid.NewGuid().ToString();
Guid id = Guid.Empty;
if (Guid.TryParse(key, out(id)) && id != Guid.Empty)
{
args["Key"] = key;
e.DynamicDownload(typeof(ContentGenerator), args);
}
}
//You must create a new class that derives from
//EO.Web.DynamicDownloadContent to dynamically
//generate the download content
private class ContentGenerator : EO.Web.DynamicDownloadContent
{
protected override void GenerateContent()
{
//Get the argument we passed in
int nLineCount = 0;
String key = string.Empty;
try
{
nLineCount = 6;
key = this.Arguments["Key"];
}
catch (Exception ex)
{
nLineCount = 1;
}
//Set the file name. You should also specify
//contentLength (the second parameter) if you
//know the content length in advance. The
//browser will not be able to display progress
//information if contentLength is not set
SetFileName("TestDownload.txt", -1);
//Generates the content
for (int i = 0; i < nLineCount; i++)
{
string line = string.Format("Line {0}\r\n", i + 1);
byte[] buffer = Encoding.ASCII.GetBytes(line);
Write(buffer, 0, buffer.Length);
}
}
}
}
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Thank you very much for the test code. We have posted a new build that should fix this problem. Please see your private message for the download location.
|
|
Rank: Member Groups: Member
Joined: 12/9/2010 Posts: 28
|
Thank you. That seems to have done the trick.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Great. Thank you very much for confirming the fix!
|
|