Re: Can I execute a javascript action before uploading a file?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Mark.

You can make the page behave like it has been submitted just with a bit
of javascript.

By default an ASP:Button object can fire an OnClick event to call a
function back on the server side. This however is essentially an
argument passed to the postback handler though and then ASP.NEt picks
it up server side before any of your processing begins and executes the
function.

So the way to fool it is keep the page as you have it now, all working
fine but the extra function you want called not being called. Once you
have it absolutely working for a basic click take a look at the code
and in particular look at the Javascript the input button calls which
ultimately results in a __doPostBack().

Trace through the function parameters and now you know the bit of JS
you need to call and what parameters to pass it in order to make the
Submit_OnClick function work on the server.

Simply change the ASP:Button object into a plain old html button
instead that with it's OnClick event fires your JS function that
disables all the buttons etc and from that function submit the form
with the JS function call you traced from the old button...

Cheers
AndrewF

.



Relevant Pages

  • Re: ASP.NET 1.1 TextBox OnClick Event
    ... ASP.NET Server Side WebControl Event. ... number in the textbox and click the button the correct page is selected. ... event will fire when the user left-clicks the control with the mouse. ... Since the OnClick Event does not work in ASP.NET 1.1 for a TextBox ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Preventing Multiple submit (Disabling Submit Button Post Click) So
    ... > This assumes javascript is enabled on the browser. ... >> they are waiting for server processing. ... Most apps these days like to ... >> button in the OnClick event in ASP.Net because then the Click event ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How to make a button to have both server side and client event in ASP.NET?
    ... > I want to make a button which have a server side OnClick event in .cs to ... But I want it to have a client side onclick event to run ... > a javascript popup too. ... And the javascript will be run only in some ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Delete confirmation box?
    ... The onclick event is calling a Javascript Confirm ... I recompiled and replaced everything on the server and it ... >> Some things that I might try would be maybe try recompiling the whole ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • How to make a button to have both server side and client event in ASP.NET?
    ... I want to make a button which have a server side OnClick event in .cs to ... a javascript popup too. ... And the javascript will be run only in some ...
    (microsoft.public.dotnet.framework.aspnet)