when user clicks button on asp.net page, need
save file
asp:fileupload
in folder on server - guess needs done in c#, in how correctly use asp.net fileupload controlrun javascript function in how call javascript function asp.net button click event
is there way combine c# , javascript achieve need? if not, how should it?
try using onclientclick
property of asp:button
element.
ex, on .aspx file:
<script type="text/javascript"> function myfunction() { alert('hi'); } </script> ... <asp:button id="button1" usesubmitbehavior="true" text="open web site" onclientclick="myfunction()" runat="server" onclick="button1_click" />
and in code behind (.aspx.cs)
void button1_click (object sender, eventargs e) { if (this.fileupload1.hasfile) { this.fileupload1.saveas("c:\\" + this.fileupload1.filename); } }
more info at
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.onclientclick.aspx
Comments
Post a Comment