I have a button (.NET 3.5) like so:
<asp:Button CssClass="app_button" ID="btnSave" Text=" Save & release " OnClientClick="return startUpload();" runat="server" />
-------
The javascript looks like this (passing in the UploadConnector ClientID ("spuUploadBase" is a user control where I expose the uploadconnector's clientid):
function startUpload()
{
if (valForm())
{
kw.get("<%= spuUploadBase.UploadConnectorID %>").submit();
return true;
}
else
{
return false;
}
}
"valForm" is a javascript function that does various checks, raises alerts, if needbe, and returns true or false (false if validation failed, true if it succeeds).
---------
I am using the "Upload Connector" control in conjunction with the "Upload Progress Display", "FileSelector", and "FileList" controls as I need to have more than one file uploader on a page at a given time. My UploadConnector looks like this:
<kw:UploadConnector ID="uploadConnector" runat="server" OnUploadComplete="up_UploadComplete" AutoUploadOnPostBack="false" />
--------
The button click code (in the vb code behind looks like so):
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
//Code taken out for bevity's sake.
End Sub
--------
What I need to have happen is this:
- User clicks on "Save" button.
- The "ValForm" code is run. If it returns false, alerting the user and preventing the postback from taking place.
- If the "valForm" code returns "true", then start the upload process and run the button click information.
What I am seeing is that when valForm (and in turn "startUpload" returns false), it works as expected. However, when it passes the valForm test it starts the upload correctly, and performs a postback (I did some "Response.Write("got here") on the IsPostBack part of the Page_Load method to confirm), however it doesn't fire the button click event code.
A co-worker and I suspect that this may be happening because the page thinks the uploader is doing the postback but not the button. Not sure if that's right or if you can point us in the right direction.
Thank you so much for your help.