I have a C# function in which I would like to call/run some JavaScript:
protected void DetailsView1_DataBound(object sender, EventArgs e) {
...
// call/run JavaScript
...
}
I'm dealing with a form, specifically, submitting the form. Upon clicking "Submit", several C# functions run that take care of validation and other miscellaneous tasks. After these are done, I need to run some JavaScript but I'm having trouble synchronizing these events. The JavaScript is:
...
if (uploader.total.uploaded == 0) {
if (uploader.files.length > 0) {
uploader.start();
}
e.preventDefault();
}
...
The way I've been trying to do this is by detecting the click event on the "Submit" button via jQuery and running my Javascript, but then the form itself doesn't submit. I've tried variations of this but I haven't had luck.
So how would I accomplish this? Is "RegisterClientScript" something that I should look into? If so, would a possible solution be registering the JavaScript on PageLoad and attaching it to the Submit button? If so, how would I do this in code?
Let me know if I need to further clarify my question.
UPDATE
A bit of clarification... the form on this page is submitted by a button:
<asp:CommandField ValidationGroup="request" ButtonType="Image"
CancelText="Reset" CancelImageUrl="../images/internal/btn_reset.gif"
InsertImageUrl="../images/internal/btn_insert.gif" ShowEditButton="True"
ShowInsertButton="True" />
This creates 2 buttons, the Insert being the Submission button so I refer to it as the Submit button.
Thanks,
Hristo