asp.net validator controls and flajaxian s3 uploader

Oct 26, 2008 at 9:01 PM
The upload form on my asp.net page includes fields such as Name, Description, Password, etc... These text fields allow users to enter meta data to describe the file they are uploading.  These fields are required and have asp.net validator controls associated with them.  The asp.net validators generate javascript that fires on the client side before the form is submitted.  How do I force the Flajaxian upload button to submit the form so that the asp.net validator controls can fire before the file is uploaded?
Thanks.
Coordinator
Oct 27, 2008 at 5:38 AM
This will be possible with Flajaxian 2.0 but it will take about a week before we can release it.
Oct 28, 2008 at 7:05 AM
Looking forward to the new version.

In the current version is it possible to call the Upload button routine programatically in .net?

What is the best way to upload the same file to three different S3 buckets with flajaxian?

Thanks.
Coordinator
Oct 28, 2008 at 7:09 AM
Use 3 amazon adapters
Oct 28, 2008 at 7:55 AM
Can you point to some code samples that can get me started?

Thanks.
Coordinator
Oct 28, 2008 at 8:29 AM
<fjx:FileUploader ID="FileUploader1" runat="server" >
    <Adapters>
        <fjxau:AmazonUploader
                AccessKey="WebConfig:AmazonAccessKey"
                SecretKey="WebConfig:AmazonSecretKey"
                BucketName="media1.flajaxian.com">
                    <AccessControlList>
                        <fjxau:AccessControl URI="http://acs.amazonaws.com/groups/global/AllUsers" Permission="READ" />
                        <fjxau:AccessControl EmailAddress="john@flajaxian.com" Permission="FULL_CONTROL" />
                    </AccessControlList>
            </fjxau:AmazonUploader>
        <fjxau:AmazonUploader
                AccessKey="WebConfig:AmazonAccessKey"
                SecretKey="WebConfig:AmazonSecretKey"
                BucketName="media2.flajaxian.com">
                    <AccessControlList>
                        <fjxau:AccessControl URI="http://acs.amazonaws.com/groups/global/AllUsers" Permission="READ" />
                        <fjxau:AccessControl EmailAddress="john@flajaxian.com" Permission="FULL_CONTROL" />
                    </AccessControlList>
            </fjxau:AmazonUploader>
        <fjxau:AmazonUploader
                AccessKey="WebConfig:AmazonAccessKey"
                SecretKey="WebConfig:AmazonSecretKey"
                BucketName="media3.flajaxian.com">
                    <AccessControlList>
                        <fjxau:AccessControl URI="http://acs.amazonaws.com/groups/global/AllUsers" Permission="READ" />
                        <fjxau:AccessControl EmailAddress="john@flajaxian.com" Permission="FULL_CONTROL" />
                    </AccessControlList>
            </fjxau:AmazonUploader>
    </Adapters>
</fjx:FileUploader>
Oct 28, 2008 at 8:44 AM
Edited Oct 28, 2008 at 8:52 AM
Thank you for that sample.

How would I overwrite the upload javascript function in my .net page?

I saw that you expose 

 

<UploadButtonChangeJsFunction>  how can I do the same thing for the upload function?...

 

upload:

function() {

 

 

if (!this._isInitialized || !this._uploadingEnabled) { return; }

 

 

if (this._isUploading) { return; }

 

 

 

this._isUploading = true;

 

 

this._setButtons(false, false, true);

 

 

this.getFlash().CallFunction("<invoke name=\"upload\" returntype=\"javascript\"><arguments/></invoke>");

 

}

 


Thanks.

 

 

 

 

Coordinator
Oct 28, 2008 at 8:55 AM
First of all the user has to select files then you can call 
<script>
document.getElementById("<%=FileUploader1.ClientID%>_UploadButton").click();
</script>
Oct 29, 2008 at 6:57 AM

I currently have the following code:

 

<

asp:Button ID="btnTest" runat="server" Text="Click" />

 

 

 

 

<div>

 

 

 

 

<fjx:FileUploader ID="FileUploader1" runat="server" >

 

</

fjx:FileUploader>

 

 

 

</div>

in Code Behind in the Page Load Event I have:

 

Dim

_AmazonUploader As New com.flajaxian.AWS.AmazonUploader()

 

_AmazonUploader.AccessKey =

"secret"

 

 

 

_AmazonUploader.SecretKey =

"secret"

 

 

 

_AmazonUploader.BucketName =

"marattestbucket"

 

 

Dim _AccessControl As New com.flajaxian.AWS.AccessControl()

 

_AccessControl.URI =

"http://acs.amazonaws.com/groups/global/AllUsers"

 

 

 

_AccessControl.Permission = com.flajaxian.AWS.Permission.READ

_AmazonUploader.AccessControlList.Add(_AccessControl)

FileUploader1.Adapters.Add(_AmazonUploader)

FileUploader1.MaxNumberFiles = 1

 

If Not Page.IsPostBack Then

 

 

 

btnTest.Attributes.Add(

"OnClick", "document.getElementById('<%=FileUploader1.ClientID%>_UploadButton').click();")

 

 

End If

 

 

I browse for the file I'd like to upload, then I click on "btnTest", and I get the following javascript error:

Error: document.getElementById("<%=FileUploader1.ClientID%>_UploadButton") is null
Source File: http://localhost:3310/FlajaxianTest/Default.aspx
Line: 1


Coordinator
Oct 29, 2008 at 7:05 AM

btnTest.Attributes.Add(

 

"OnClick", "document.getElementById('"+FileUploader1.ClientID+"_UploadButton').click();"

Oct 29, 2008 at 7:22 AM
i changed it to:

 

If Not Page.IsPostBack Then

 

btnTest.Attributes.Add(

"OnClick", "document.getElementById('" + FileUploader1.ClientID + "_UploadButton').click();")

 

 

End If

and now I'm getting a different javascript error:

Error: document.getElementById("FileUploader1_UploadButton").click is not a function
Source File: http://localhost:3310/FlajaxianTest/Default.aspx
Line: 1

 

Coordinator
Oct 29, 2008 at 7:40 AM
document.getElementById("FileUploader1_UploadButton").firstChild.click()
Oct 29, 2008 at 7:52 AM
That worked.  It's calling the Upload javascript function.
But it doesn't seem to upload.  I don't see the progress bar, like I do when I click your upload button.  Also when I try to see if the file is there I get an access denied message from S3.  When I upload the same file using your upload button it works fine.

Not sure what the problem could be in this case.  Can you help?

Sorry to keep bugging you and thanks again.
Oct 30, 2008 at 4:44 PM
File is not uploading.  Even though I can see that the Upload javascript function is getting called.  It looks like the file is not uploading.  I don't see the flash progress bar and I don't see the file on S3.

Coordinator
Oct 30, 2008 at 5:09 PM
Sorry I am about to finish 2.0 and I won't have time in the next few days to help with 1.0 support. You have the source try to analyse it. Debug with Fiddler.
Oct 31, 2008 at 9:29 AM
I know you're busy. I have a quick question. Hopefully you can help.  I have the following code in my test asp.net page

<

html xmlns="http://www.w3.org/1999/xhtml" >

 

<

head runat="server">

 

 

<title>Untitled Page</title>

 

 

<script type="text/javascript">

 

 

function HandleUpload()

 

{

CallWebServiceToSaveElement();

}

 

 

function CallWebServiceToSaveElement() {

 

 

//alert("1");

 

WebServiceSaveElementOnSuccess(1244442);

}

 

 

function WebServiceSaveElementOnSuccess(result) {

 

<%=FileUploader1.ClientID%>.setStateVariable(

"id", result);

 

<%=FileUploader2.ClientID%>.setStateVariable(

"id", result);

 

<%=FileUploader1.ClientID%>.setStateVariable(

"isElement", "true");

 

<%=FileUploader2.ClientID%>.setStateVariable(

"isElement", "false");

 

 

//alert("2");

 

document.getElementById(

"FileUploader1_UploadButton").firstChild.click();

 

}


In the 

 

public

override void ProcessFile(HttpPostedFile file, Hashtable state) in the AmazonUploader.cs class

the file comes in, but the state is empty.  I've traced through the javascript and I see that state is being passed into the flash function.  But it's not making it out of there to the ProcessFile function.

What could be the problem?

Thanks for your time.

 

Coordinator
Oct 31, 2008 at 4:30 PM
Hashtable state is a different concept. A state passed between different adapters. This is something I removed in 2.0 as noone seems to use it.

The state you are looking for is in HttpContext.Current.Request["id"]