Image Button To Do A submit

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Image Button To Do A submit

Guest-1101

Hi

I have a multiFile control and try to select a couple of files at once.

When I try to do a postback using a regular asp.net button and everything works great and the correct fucntion is being called.

But if I replace a regular asp.net button with an image button, then the page will post back, but it will not call the function that has been assigned with the image button.

This only happens after I have selected the files to upload.

If i didnt selecte any file in multiFile, the image button will post back correctly to the code behind function.

Do I need to handle image button specially?

Thank you

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image Button To Do A submit

Dean Brettle
Administrator
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image Button To Do A submit

Guest-1101
I am having  a similar problem. I am using an asp image button to submit the form that has a multifile control .. Everything works and the code behind for the image button click event is running .( I tested it by using an Input file control). It seems  that maybe the Uploaded file array is cleared when the form is submitted with an asap image button.. this is just a guess. So I dont know what else to try and debug this
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image Button To Do A submit

Guest-1101
I have done a little more debugging and this does not occur if I dont use flash for selecting multiple files.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image Button To Do A submit

Dean Brettle
Administrator
Have you tried the workarounds described at:

Clicking submit buttons or image buttons might start the progress display or clear selected files

If they don't help, please email me (dean at brettle dot com) a small test app that demonstrates the problem and indicate what version of NeatUpload, ASP.NET, IIS, browser, and Flash player you are using.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image Button To Do A submit

Daniel Covington
I have looked at the article you mentioned and used the example. My problem is, is that I want the image button to do a post back and start the upload. Everything works the way I would like until I switch the multifile control  to use  flash. Then the image button will trigger the upload but the onclick function either does not fire or clears the Uploaded file Array and I cannot process the files as needed. A regular ASP button does not have this problem. I will send a small test project to duplicate the results.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image Button To Do A submit

Guest-1101

I have been using Win XP as development and testing box, IIS version 5.1, flash 10.0.45.2 , and IE 8 is the main browser I use. I am using the latest version of Neat Upload as well. I have removed the branding on this app. The app has a multi file control, an ASP image button, a regular ASP button, and the Grey Box progress bar.  The app tells you if flash is enabled and what triggers are set for the upload to begin. After the upload completes, a list of the files uploaded should be displayed - the same as your demo app that is included with the download.  Let me know if you need any other info.

I have tried to email you a small app as a zip file but it keeps getting bounced. So I guess I will just post the contents of the files here.

Default.aspx page

<%@ Page Language="VB" Debug="true" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register Assembly="Brettle.Web.NeatUpload.GreyBoxProgressBar"

Namespace="Brettle.Web.NeatUpload" TagPrefix="GreyBoxUpload" %>

<%@ Register Assembly="Brettle.Web.NeatUpload, Version=1.3.3750.27538, Culture=neutral, PublicKeyToken=5cac0022fdac126a"

Namespace="Brettle.Web.NeatUpload" TagPrefix="Upload" %>

<!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>Untitled Page</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<Upload:MultiFile ID="MultiFile1" runat="server" UseFlashIfAvailable="True">

</Upload:MultiFile><br />

<GreyBoxUpload:GreyBoxProgressBar ID="GreyBoxProgressBar1"

runat='server'>

</GreyBoxUpload:GreyBoxProgressBar>

<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/button.png" /><br />

<asp:Button ID="Button1" runat="server" Text="Button" style="color: white; background-color: orange" />

 

 

</div>

<pre id="flash" runat="server"></pre>

<pre id="prebody" runat="server"></pre>

</form>

</body>

</html>

Default.aspx.vb

Partial Class _Default

Inherits System.Web.UI.Page

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

AddHandler ImageButton1.Click, AddressOf Me.IMG_Click

AddHandler Button1.Click, AddressOf Me.Button_Clicked

If MultiFile1.UseFlashIfAvailable = True Then

flash.InnerText = "Flash option is On" & vbLf

Else

flash.InnerText = "Flash option is Off" & vbLf

End If

flash.InnerText += "Upload triggers are:" & GreyBoxProgressBar1.Triggers

End Sub

Sub IMG_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click

MultiFile1.UseFlashIfAvailable = False

prebody.InnerText = "ASP Image Button Pressed"

 

If MultiFile1.Files.Length > 0 Then

prebody.InnerText = "Uploaded " & MultiFile1.Files.Length & " files with MultiFile Image Button Submit:" & vbLf

For Each file As Brettle.Web.NeatUpload.UploadedFile In MultiFile1.Files

prebody.InnerText += file.FileName & vbLf

Next

End If

End Sub

Sub Button_Clicked(ByVal sender As Object, ByVal e As EventArgs)

prebody.InnerText = "ASP Button Pressed"

 

If MultiFile1.Files.Length > 0 Then

prebody.InnerText = "Uploaded " & MultiFile1.Files.Length & " files with MultiFile ASP Button Submit:" & vbLf

For Each file As Brettle.Web.NeatUpload.UploadedFile In MultiFile1.Files

prebody.InnerText += file.FileName & vbLf

Next

End If

End Sub

End Class

web.config

<?xml version="1.0"?>

<!--

Note: As an alternative to hand editing this file you can use the

web admin tool to configure settings for your application. Use

the Website->Asp.Net Configuration option in Visual Studio.

A full list of settings and comments can be found in

machine.config.comments usually located in

\Windows\Microsoft.Net\Framework\v2.x\Config

-->

<configuration>

<appSettings/>

<connectionStrings/>

<system.web>

<!--

Set compilation debug="true" to insert debugging

symbols into the compiled page. Because this

affects performance, set this value to true only

during development.

Visual Basic options:

Set strict="true" to disallow all data type conversions

where data loss can occur.

Set explicit="true" to force declaration of all variables.

-->

<compilation debug="false" strict="false" explicit="true">

<assemblies>

<add assembly="Brettle.Web.NeatUpload, Version=1.3.3750.27538, Culture=neutral, PublicKeyToken=5CAC0022FDAC126A"/>

<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>

<pages>

<namespaces>

<clear/>

<add namespace="System"/>

<add namespace="System.Collections"/>

<add namespace="System.Collections.Specialized"/>

<add namespace="System.Configuration"/>

<add namespace="System.Text"/>

<add namespace="System.Text.RegularExpressions"/>

<add namespace="System.Web"/>

<add namespace="System.Web.Caching"/>

<add namespace="System.Web.SessionState"/>

<add namespace="System.Web.Security"/>

<add namespace="System.Web.Profile"/>

<add namespace="System.Web.UI"/>

<add namespace="System.Web.UI.WebControls"/>

<add namespace="System.Web.UI.WebControls.WebParts"/>

<add namespace="System.Web.UI.HtmlControls"/>

</namespaces>

</pages>

<!--

The <authentication> section enables configuration

of the security authentication mode used by

ASP.NET to identify an incoming user.

-->

<authentication mode="None"/>

<!--

The <customErrors> section enables configuration

of what to do if/when an unhandled error occurs

during the execution of a request. Specifically,

it enables developers to configure html error pages

to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

<error statusCode="403" redirect="NoAccess.htm" />

<error statusCode="404" redirect="FileNotFound.htm" />

</customErrors>

-->

<httpModules>

<add name="UploadHttpModule" type="Brettle.Web.NeatUpload.UploadHttpModule, Brettle.Web.NeatUpload,Version=1.3.3750.27538, Culture=neutral, PublicKeyToken=5CAC0022FDAC126A"/>

</httpModules>

</system.web>

</configuration>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image Button To Do A submit

Dean Brettle
Administrator
Thanks for the bug report and test case.  I've been able to reproduce the problem and should have a fix in the next couple days.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image Button To Do A submit

Daniel Covington
Thats great. I actually just used a regular asp button skinned to look the way I want. I am curious to know what the bug is though when you get it figured out.. Thanks again for the great custom control you have made.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image Button To Do A submit

Dean Brettle
Administrator
When doing a Flash-based upload, NeatUpload needs to wait for Flash to complete the upload before it submits the html form. To do that, it eats the original button click, waits for Flash to finish, and then fakes the button click by adding a hidden form field before submit()ing the form. For regular submit buttons that works fine. For image buttons it looks like I need to add 2 hidden form fields, one for the x and one for the y coord of where the user clicked on the image. Determining where the user clicked on the image is a little tricky but I think I've figured it out.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image Button To Do A submit

Dean Brettle
Administrator
Fixed in NeatUpload-1.3.24 which was just released.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image Button To Do A submit

daniel147
In reply to this post by Guest-1101
I suggest that you shuold not use flash to select files and conduct more debugging, the image button problem will be solved.
Loading...