| protected void submitbutton_Click(object sender, EventArgs e) |
| { |
| //checks credentials, returns 1 or 0 |
| int authStatus = Authentication.AuthenticateEmployee(txtUsername.Text.Trim(), |
| Encryption.encryptStringSHA256(txtPassword.Text.Trim())); |
| switch (authStatus) |
| { |
| case 0: |
| lblStatus.Text = "code0: Your user does not have access"; |
| break; |
| case 1: |
| lblStatus.Text = "code1: Successfull"; |
| //here i want it to close the radwindow and run some server side code. |
| break; |
| } |
| } |
function SaveDashboard(pane, eventArgs) { loadingPanel = $find(radAjaxLoadingPanel1ID); loadingPanel.show(baseSplitterID); eventArgs.set_cancel(true); window.PageMethods.SaveToDatabase( function (result) { if (result == true) { window.radalert('Dashboard saved successfully.', 275, 100, "Save Successful"); } else { window.radalert('Dashboard NOT saved successfully.', 240, 100, "Save Unsuccessful"); } loadingPanel.hide(baseSplitterID); });}I am using the AsyncUpload control to upload an employee picture to a telerik AJAX Manager enabled website. The <ASP:IMAGE> tag that displays the picture is embedded in a Telerik Rad Ajax Loading Panel.
When I upload the picture (to the temporary folder) and then click the page submit button, the employee picture is correctly saved to the temporary folder and then moved to the target folder.
As people can potentially upload pictures with the same filename, they can clobber each other's previously uploaded files inside the target folder. I've added logic in the server side submit button handler to rename each uploaded targetfolder file so that it is always unique to a particular employee. Each employee will end up retaining this filename as it is based on a formula that uses an employee number, even for future subsequent uploads. At the end of the submit button handler, I repopulate the screen controls.
If I upload two different pictures for the same screen without leaving it, the first upload renders the picture. On the second upload, the picture doesn't change even though its content and timestamp HAS changed in the target folder. The reason it doesn't refresh on the second upload is that the <ASP:IMAGE> tag is using the same filename it had from the first upload. The ajax mechanism doing the background postback isn't telling something (internet explorer?) to reload the image from the targetfolder.
How do I get the uploaded file to be marked as being dirty so that a refresh on the <ASP:IMAGE> tag is forced?
protected void btnSave_Click(object sender, EventArgs e) { System.String result = "OK"; System.String strUploadedFileName = ""; System.String strUploadedFileExtension = ""; System.String strNewEmployeePhotoName = ""; System.String strEmployeePicturesPath = ""; try { System.String strCoordinatorID = lblCoordinatorID.Text.Trim(); if (strCoordinatorID != "") { EmployeeInfo coordinator = EmployeeInfo.GetEntity(strCoordinatorID); if (upldPicture.UploadedFiles.Count>0) { strEmployeePicturesPath = getMappedFolderPathTo("EmployeePictures"); strUploadedFileName = upldPicture.UploadedFiles[0].FileName; //file is located in targetfolder at this point strUploadedFileExtension = upldPicture.UploadedFiles[0].GetExtension(); strNewEmployeePhotoName = "COORDINATOR_" + strCoordinatorID + strUploadedFileExtension; //rename the file so that it can't be clobbered by someone else uploading another file with same name if (File.Exists(@strEmployeePicturesPath + strNewEmployeePhotoName) == true) { File.Delete(@strEmployeePicturesPath + strNewEmployeePhotoName); //delete any leftover picture } File.Move(@strEmployeePicturesPath + strUploadedFileName, @strEmployeePicturesPath + strNewEmployeePhotoName); //do a move incase the source is still open File.Delete(@strEmployeePicturesPath + strUploadedFileName); //delete the original file that was uploaded } if (coordinator != null) { //update existing coordinator if (strNewEmployeePhotoName!="") { coordinator.employeePhotoFileName = strNewEmployeePhotoName; } EmployeeInfo.Update(coordinator); } else { //its a new coordinator so add it } result = LoadCoordinator(ref coordinator, userpage.editor); //refresh the page }//strCoordinatorID != "" } catch (Exception ex) { System.Object oe = (Object)ex; result = "btnSave_Click: " + et.rptError(ref oe); }//try lblMsg.Text = result; }//EOF btnSave_Click<ClientEvents OnMasterTableViewCreated="DoStuff" />
function DoStuff(sender, args) { var tabStrip = $find("<%= MainTabStrip.ClientID %>"); var pageViewID = tabStrip.get_multiPage().get_selectedPageView()._id; ... } function DoStuff(sender, args) { setTimeout(function() { var tabStrip = $find("<%= MainTabStrip.ClientID %>"); var pageViewID = tabStrip.get_multiPage().get_selectedPageView()._id; }, 0); ... }textboxname.Style.Add(HtmlTextWriterStyle.BackgroundColor, "red");sender.get_styles().EnabledStyle[0] = sender.get_styles().EnabledStyle[0].replace("background-color:red;", ""); sender.updateCssClass();