Click here to Skip to main content
15,913,709 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: master page Pin
RajeevKumarSharma7-Jan-08 0:19
RajeevKumarSharma7-Jan-08 0:19 
Generalaccessing data Pin
nicetohaveyou6-Jan-08 19:02
nicetohaveyou6-Jan-08 19:02 
QuestionCrystal Reports? Pin
Kasi Viswanathan6-Jan-08 18:27
Kasi Viswanathan6-Jan-08 18:27 
GeneralRe: Crystal Reports? Pin
N a v a n e e t h6-Jan-08 20:29
N a v a n e e t h6-Jan-08 20:29 
GeneralThread: Data List delete button problem. [modified] Pin
Albert836-Jan-08 12:16
Albert836-Jan-08 12:16 
GeneralRe: Thread: Data List delete button problem. Pin
N a v a n e e t h6-Jan-08 16:33
N a v a n e e t h6-Jan-08 16:33 
GeneralRe: Thread: Data List delete button problem. Pin
Albert836-Jan-08 16:41
Albert836-Jan-08 16:41 
GeneralOne step FileUpload Pin
David Kalkwarf6-Jan-08 5:39
David Kalkwarf6-Jan-08 5:39 
It seems that the "normal" method for using the FileUpload (or HTML file) control is for the user to choose the file with the upload control, then provide another button (or link or something else) to process that file. So, the user chooses the file, then clicks the other control to update or save the file. I would like to make this a one step process where the file is processed as soon as the user chooses the file. The nicest solution would have been handling a FileUpload control event that indicated when the user had chosen the file and it was uploaded, but there doesn't appear to be any such event.

With help from a CodeProject article, I wrote some javascript to trigger the file upload. The javascript is called in the Click event handler of another button. After the user chooses the file, it continues to the handler to do what I wanted (save to database and update screen). See the code below:

function getFile()<br />
{<br />
   var uploadCtrl = document.getElementById("File1");<br />
   <br />
   // trigger the file upload Browse button, then asp:Button Click handler<br />
   uploadCtrl.click();<br />
 }<br />
<br />
protected void Page_Load(object sender, EventArgs e)<br />
 {<br />
    Button1.Attributes.Add("OnClick", "return getFile();");<br />
 }<br />
   <br />
protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
   if (File1.PostedFile != null)<br />
   {<br />
      // do my thing<br />
   }<br />
}



It only gets to Button1_Click after the upload if I remove 'runat="server"' from the HTML file control definition. The problem is that I need 'runat' to get access to PostedFile etc.

Does anyone have any suggestions? If you can fix the above method, I would be very happy. If you have a better way of solving my problem, then I am still happy. If you can educate me on why the above method does what it does, I am always happy to learn.


Thanks,

Dave
GeneralSystem.Web.HttpUtility.UrlEncode() help help help help Pin
Ahmad Adnan6-Jan-08 3:31
Ahmad Adnan6-Jan-08 3:31 
Generalsave Bitmap ...... Pin
galigal156-Jan-08 3:26
galigal156-Jan-08 3:26 
AnswerRe: save Bitmap ...... Pin
Guffa6-Jan-08 5:20
Guffa6-Jan-08 5:20 
GeneralRe: save Bitmap ...... Pin
galigal156-Jan-08 20:34
galigal156-Jan-08 20:34 
GeneralRe: save Bitmap ...... Pin
Guffa6-Jan-08 20:42
Guffa6-Jan-08 20:42 
GeneralRe: save Bitmap ...... Pin
galigal156-Jan-08 23:08
galigal156-Jan-08 23:08 
GeneralRe: save Bitmap ...... Pin
Guffa7-Jan-08 11:02
Guffa7-Jan-08 11:02 
GeneralRe: save Bitmap ...... Pin
galigal157-Jan-08 19:01
galigal157-Jan-08 19:01 
QuestionStart Windows Service throw web application and Access Denied exception [modified] Pin
mkomasi6-Jan-08 0:48
mkomasi6-Jan-08 0:48 
GeneralDoesnt Fire the Page_load Method Pin
M_Menon5-Jan-08 23:25
M_Menon5-Jan-08 23:25 
GeneralRe: Doesnt Fire the Page_load Method Pin
Christian Graus5-Jan-08 23:53
protectorChristian Graus5-Jan-08 23:53 
GeneralRe: Doesnt Fire the Page_load Method Pin
M_Menon6-Jan-08 1:21
M_Menon6-Jan-08 1:21 
GeneralRe: Doesnt Fire the Page_load Method Pin
N a v a n e e t h6-Jan-08 7:42
N a v a n e e t h6-Jan-08 7:42 
GeneralRe: Doesnt Fire the Page_load Method Pin
M_Menon7-Jan-08 19:35
M_Menon7-Jan-08 19:35 
QuestionQuery String Pin
Mr. Wonderful5-Jan-08 8:58
Mr. Wonderful5-Jan-08 8:58 
GeneralRe: Query String Pin
DigiOz Multimedia5-Jan-08 9:04
DigiOz Multimedia5-Jan-08 9:04 
GeneralRe: Query String Pin
Paul Conrad5-Jan-08 9:46
professionalPaul Conrad5-Jan-08 9:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.