c# - Run Javascript when Asp.net page is loading -
i wonder if there way run js code whenever asp.net page contacting server. i.e. i'm looking general event handler triggered whenever call server made runat="server" components.
i know there's way jquery.ajax() run js code before , after call server made, i'm not sure how in asp.net. especially, since projects uses lot of custom components.
the goal here show kind of loading image when button clicked, prevent user click button twice , show user system working.
if click causes page or updatepanel refresh, i'd display loading image before refresh, eg. user clicks, "loading" shown, page/update panel refreshed (causing "loading" disappear), new page/content displayed normal.
update 1: can't use updateprogress because of buttons aren't inside updatepanels. want fire js button/control contact server clicked. i.e. if user clicks dropdown doesn't contact server, nothing should happend. if dropdown has connection server, js should run.
i understand asp.net ajax , not jquery ajax, used jquery example. because i've used jquery method before (with jquery ajax) trigger js before server call made. eg. lock element clicked or display "loading..." screen.
i of course add bit of js hack every page adds "onclick" event every button manually, thought better if there general solution (since i've got lots of pages, each few buttons contact server on them).
update 2: when think it, doesn't need js triggered. enough if page somehow made sure same button wasn't clicked twice. either disabeling button or adding in front of (like "loading..." screen).
you can use updateprogress use update panels, if doing full page postback (i.e. not ajax) loading animation can have browsers own.
updateprogress:
<asp:updateprogress id="updateprogress1" runat="server"> <progresstemplate> shiny loading aninmation </progresstemplate> </asp:updateprogress?
Comments
Post a Comment