protected void upload_document_Click(object sender, EventArgs e) { try { if (!DocumentUploader.HasFile) throw new Exception("Please provide a file."); long convertedStudentId; if (!Int64.TryParse(Session["userid"].ToString(), out convertedStudentId)) throw new Exception("Cannot find user ID, please contact administrator."); string filename = DocumentUploader.FileName; FileModule fileModule = new FileModule(); ProjectDocument projectDocument = fileModule.saveProjectFile(DocumentUploader.PostedFile.InputStream, FILE_TYPE.DOCUMENT,filename); uploaded_document_info.Text = filename; //store ID in hidden_uploaded_doc_ID hidden_uploaded_doc_ID.Value = projectDocument.PROJECTFILE_ID.ToString(); Messenger.setMessage(error_message, "File uploaded successfully.", LEVEL.SUCCESS); //refreshCategoryList(); } catch (SaveFileException sfex) { Messenger.setMessage(error_message, sfex.Message, LEVEL.DANGER); } catch (Exception ex) { Messenger.setMessage(error_message, ex.Message, LEVEL.DANGER); } finally { error_modal_control.Show(); //NewProjectUpdatePanel.Update(); selected_categories.Value = ""; } }