Click here to Skip to main content
15,906,558 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Pass ViewModel to view twice Pin
Nathan Minier25-Feb-16 1:53
professionalNathan Minier25-Feb-16 1:53 
QuestionGet file size from File Upload from IE and Chrome Pin
indian14324-Feb-16 15:49
indian14324-Feb-16 15:49 
AnswerRe: Get file size from File Upload from IE and Chrome Pin
F-ES Sitecore25-Feb-16 0:46
professionalF-ES Sitecore25-Feb-16 0:46 
QuestionSet the file upload value Pin
indian14324-Feb-16 11:24
indian14324-Feb-16 11:24 
AnswerRe: Set the file upload value Pin
Richard Deeming25-Feb-16 2:21
mveRichard Deeming25-Feb-16 2:21 
Questionfile upload, restricting size and type of files Pin
indian14324-Feb-16 7:43
indian14324-Feb-16 7:43 
AnswerRe: file upload, restricting size and type of files Pin
Richard Deeming24-Feb-16 7:56
mveRichard Deeming24-Feb-16 7:56 
GeneralRe: file upload, restricting size and type of files Pin
indian14324-Feb-16 12:54
indian14324-Feb-16 12:54 
I am not familiar much with using the jquery libraries and I am sorry but I am not good in using built-in Java Script libraries like Kendo or from some other vendors etc.

I am writing my own JavaScript code.

Can you please help me in setting the value of the File upload when user selected the wrong file, it should either set to empty or "No file chosen" as it says in the begging, but Webforms file upload is showing the wrongly selected file in the file path box. Remaining script I was able to manage.

Can you please help me in this, any help like a code snippet, a link or even a suggestion helps me great. Thanks in advance buddy.
Like in the below function I need to set the value of the file upload to "No file chosen", if I try to set it up its not setting with value or val property.
    <script type="text/javascript">
        function CheckImageTypeAndSize() {
            var aspFileUpload = document.getElementById("FileUpload1");
            var errorLabel = document.getElementById("lbl_uploadMessage");
            var img = document.getElementById("imgUploadThumbnail");           

<pre>
        var fileName = aspFileUpload.value;<br />
        var fileSize; errorLabel.innerHTML = "";

        try {
            fileSize = aspFileUpload.files[0].size; // Size returned in bytes.
        } catch (e) {
            var objFSO = new ActiveXObject("Scripting.FileSystemObject");
            var e = objFSO.getFile(aspFileUpload.value);
            fileSize = e.size;<br />
        }            

        var ext = fileName.substr(fileName.lastIndexOf('.') + 1).toLowerCase();
        if (!(ext == "docx" || ext == "doc" || ext == "pdf")) {
            errorLabel.innerHTML = "Invalid image file, must select a *.doc, *.docx, or *.pdf file.";
            return false;
        }
        if (img.fileSize == -1) {
            errorLabel.innerHTML = "Couldn't load doc file size.  Please try to save again.";
            return false;
        }
        else if (img.fileSize <= 2097152) {
            errorLabel.innerHTML = fileName;
            return true;
        }
        else {                
            var fileSize = (fileSize / 1048576);
            errorLabel.innerHTML = "File is too large, must select file under 20 Mb. File  Size: " + fileSize.toFixed(1).toString() + " Mb";
            return false;
        }
    }



Thanks,

Abdul Aleem

"There is already enough hatred in the world lets spread love, compassion and affection."

AnswerRe: file upload, restricting size and type of files Pin
F-ES Sitecore25-Feb-16 0:43
professionalF-ES Sitecore25-Feb-16 0:43 
QuestionHow to filter data in DataTable using like operator ? Pin
Member 1228492023-Feb-16 19:04
Member 1228492023-Feb-16 19:04 
QuestionRe: How to filter data in DataTable using like operator ? Pin
Richard MacCutchan23-Feb-16 21:32
mveRichard MacCutchan23-Feb-16 21:32 
AnswerRe: How to filter data in DataTable using like operator ? Pin
aarif moh shaikh26-Feb-16 21:04
professionalaarif moh shaikh26-Feb-16 21:04 
Questionhow to bind Database field value in textbox based on choosing dropdownlist selected value in asp.net MVC Pin
Nithu Nithiya23-Feb-16 18:06
professionalNithu Nithiya23-Feb-16 18:06 
AnswerRe: how to bind Database field value in textbox based on choosing dropdownlist selected value in asp.net MVC Pin
John C Rayan27-Feb-16 21:39
professionalJohn C Rayan27-Feb-16 21:39 
QuestionDownload file from memorystream by client side click Pin
indian14323-Feb-16 13:33
indian14323-Feb-16 13:33 
AnswerRe: Download file from memorystream by client side click Pin
Richard MacCutchan23-Feb-16 21:29
mveRichard MacCutchan23-Feb-16 21:29 
GeneralRe: Download file from memorystream by client side click Pin
indian14324-Feb-16 7:21
indian14324-Feb-16 7:21 
QuestionDropdownlist with Model (MVC4,C#, ASP.Net2015,Razor) Pin Pin
bl4ckeagle23-Feb-16 8:12
bl4ckeagle23-Feb-16 8:12 
QuestionFeedback form on my website to email feedback Pin
Member 1033668221-Feb-16 11:03
Member 1033668221-Feb-16 11:03 
AnswerRe: Feedback form on my website to email feedback Pin
Richard MacCutchan21-Feb-16 22:07
mveRichard MacCutchan21-Feb-16 22:07 
GeneralRe: Feedback form on my website to email feedback Pin
Member 1033668222-Feb-16 3:19
Member 1033668222-Feb-16 3:19 
GeneralRe: Feedback form on my website to email feedback Pin
bVagadishnu22-Feb-16 9:37
bVagadishnu22-Feb-16 9:37 
GeneralRe: Feedback form on my website to email feedback Pin
F-ES Sitecore22-Feb-16 22:31
professionalF-ES Sitecore22-Feb-16 22:31 
QuestionProblem ASP.NET MVC in IIS, RedirectToAction() and Redirect() Pin
Viadi21-Feb-16 3:48
Viadi21-Feb-16 3:48 
AnswerRe: Problem ASP.NET MVC in IIS, RedirectToAction() and Redirect() Pin
2374121-Feb-16 5:31
2374121-Feb-16 5:31 

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.