PDA

View Full Version : [CLOSED] problem with IE using IsUpload = "true" for a click event to trigger a download



CarpFisher
May 09, 2012, 6:09 PM
Hi

I have a button which triggers downloading of a file. In the DirectEvent of the Click I added IsUpload="true". It works perfectly in Chrome but not in IE.

IE prompt a security warning on top of the browser. Then if you click "download" there, IE seems to trigger a page refresh (or a postback?) all by iteself. Then my page get reload and I have to navigate all the way back to that button. If I click that button again, this one it will pop up the "save" dialog. If this the IE problem that is unavoidable? or something that can be fixed by Ext.net?


Chris

Vladimir
May 09, 2012, 6:24 PM
I am affraid that single way to deactivate that security warning in IE options (or add your site to trusted zone of IE)
By the way, I tested with IE9 (under Vista) the following sample and don't see any warning, can you confirm it?
http://examples2.ext.net/Examples/GridPanel/Miscellaneous/Export_Data_Ajax/

CarpFisher
May 10, 2012, 7:49 AM
Thank you very much again!

I can confirm that the example you gave me does not cause a security warning in my IE8. When I looked in the source code it does a "grid.submit" data, which I think would simulate a form submission which IE think that's OK and not poping up the warning.

Now what I have is a button and a DirectEvent of a Click , and it is inside a formPanel, and it doesn't seem to behave the same as the example.


I don't mind if the security warning, but I don't want the side effect of a page refresh or reload, and which I think it might be somehow caused by the clientside script. Is it because that button click is not simulating a form submission properly?

CarpFisher
May 10, 2012, 8:44 AM
It looks like the click event on DirectEvent is different than using Listener to DirectMethods.

This will generate a warning and cause a page refresh:


<ext:Button ID="Button2" runat="server" Text="S2">
<DirectEvents>
<Click OnEvent="GetReportDirectEvent" IsUpload="true" />
</DirectEvents>
</ext:Button>



And this won't:


<ext:Button ID="Button2" runat="server" Text="S2">
<Listeners>
<Click Handler="#{DirectMethods}.GetReportDirectMethod( {isUpload:true});"></Click>
</Listeners>
</ext:Button>


Both of GetReportDirectEvent and GetReportDirectMethod are executing the same code in my code behind.

Hope this help other people

Daniil
May 10, 2012, 11:18 AM
It appears I see the same behaviors of DirectEvent and DirectMerhod uploading. Generally, there should not be any difference.

I am testing with the example below.

Could you test it as well? Does it reproduce the issue on your side?

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Upload(object sender, DirectEventArgs e)
{
this.FileUploadField1.PostedFile.SaveAs("C:\\Documents\\TESTFILE.txt");
}

[DirectMethod]
public void Upload()
{
this.FileUploadField1.PostedFile.SaveAs("C:\\Documents\\TESTFILE.txt");
}
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:FileUploadField ID="FileUploadField1" runat="server" Width="300" />

<ext:Button runat="server" Text="Upload via DirectEvent">
<DirectEvents>
<Click OnEvent="Upload" IsUpload="true" />
</DirectEvents>
</ext:Button>

<ext:Button runat="server" Text="Upload via DirectMethod">
<Listeners>
<Click Handler="App.direct.Upload({ isUpload : true });" />
</Listeners>
</ext:Button>
</form>
</body>
</html>

CarpFisher
May 10, 2012, 1:51 PM
I've tried to just try it. it seems that it has null reference for

this.FileUploadField1.PostedFile

so I tried to upload a file first, but clicking "browse..." button in the FileUploadField nothing happen. I've never use that FileUploadField before so I'm not sure if that is my problem. I am using the version of DLL I got from Nuget version 2.0.4449.39235... I've tried to use the source code from the examples of the fileUploadfield also not working here.


so i changed your code to this to avoid using FileUploadField:



<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Upload(object sender, DirectEventArgs e)
{

u();
}

[DirectMethod]
public void Upload()
{
u();
}


public void u()
{

HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/docx";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=proposal.docx");


HttpContext.Current.Response.TransmitFile("c:\\tes.txt");

HttpContext.Current.Response.End();
}
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<form id="Form1" runat="server">


<ext:FileUploadField ID="FileUploadField1" runat="server" />

<ext:Button ID="Button1" runat="server" Text="Upload via DirectEvent">
<DirectEvents>
<Click OnEvent="Upload" IsUpload="true" />
</DirectEvents>
</ext:Button>

<ext:Button ID="Button2" runat="server" Text="Upload via DirectMethod">
<Listeners>
<Click Handler="App.direct.Upload({ isUpload : true });" />
</Listeners>
</ext:Button>
</form>
</body>
</html>


I can confirm that the two buttons behave differently in IE 8, one causes security warning (and a page refresh) and one doesn't

But they work the same in Chrome.

Daniil
May 10, 2012, 2:45 PM
My fault, I though you upload a file, but you download. FileUploadField is really not required to download.

The issue is not reproducible on my side with IE9 in IE8 mode. I have no native IE8 at the moment to test.

Is the issue reproducible on your side with IE9?

Vladimir
May 10, 2012, 4:00 PM
DirectEvent and DirectMethod are used the same transport.
Strictly, DirectMethod is DirectEvent with special options (just service info for server side)

I see only one difference: be default, DirectEvent uses 20 ms delay before execution

When you have a chance please update from SVN (i commited code to allow remove the delay), set Delay="0" for DirectEvent and retest
Please let us know about the result

CarpFisher
May 11, 2012, 7:43 AM
Sorry I don't have IE9 here and our company has strict policy that browser that's the only reason why I use IE... if I have a choice I will never use IE....

Is that delay not a configurable value in runtime? Only can do that in design time? BTW I still struggle to get access to SVN. I can't find the license key or SVN account details in the spam folder....

Daniil
May 11, 2012, 9:59 AM
Is that delay not a configurable value in runtime? Only can do that in design time?

Generally, yes.

Please clarify what is the case you would like to set up Delay for DirectEvent run time?


BTW I still struggle to get access to SVN. I can't find the license key or SVN account details in the spam folder....

Apologize for the inconvenience. Our manager is on the conference at the moment. It appears he is very busy. Hopefully, you will get the credentials as soon as possible. Please clarify did you send a request to support@object.net?

If you wish I can send the last Ext.Net.dll to your e-mail for now.

CarpFisher
May 16, 2012, 8:45 AM
I still haven't got access to the SVN :(

Would you please send it to my email. Thank you so much

Daniil
May 16, 2012, 9:49 AM
Our manager is back from the conference. I think you will get an access today/tomorrow.

What it the e-mail to send the dlls?

Daniil
May 16, 2012, 6:52 PM
As far as I can understand you have got the credentials.

Please clarify can we mark the thread as closed?

CarpFisher
May 17, 2012, 3:35 PM
Thank you very much I've got access to the SVN.

However just want to comment on integrating the source into your project. As it took me like 2 hours to get it done correctly.

First I need to remove all the packages that I've got from Nuget related to Ext.Net. Second I need to change the Build type to Any CPU (coz the source is default to x64, and my machine is 32bit), then I need to go through each sub-projects which depends on Ext.Net to reference to the new Ext.Net project. It took me long time because I don't know it was compiling as 64 bit image and the website keeps complaining about badimage.

Anyway thanks at last I can get a working code now.

Daniil
May 17, 2012, 6:54 PM
First I need to remove all the packages that I've got from Nuget related to Ext.Net.

The NuGet Uninstall-Package could help to do that.


Second I need to change the Build type to Any CPU (coz the source is default to x64, and my machine is 32bit)

Well, Any CPU is default on my side. I have no idea at the moment why there was x64 on your side.


then I need to go through each sub-projects which depends on Ext.Net to reference to the new Ext.Net project.

Do you have any suggestion how we could help on that?

CarpFisher
May 18, 2012, 7:24 AM
Thanks I don't think these processes are unavoidable. I'm not complaining I just want to point it out what things to look for when they change from Nuget to the SVN source, which might help save a bit of time.

Daniil
May 18, 2012, 7:29 AM
Ok, thanks for pointing out the problem. We will review.