Solved

How do I reference the fileuploader, trying to make msgbox appeaer if fileuploader hasnt been submitted

Posted on 2008-10-13
8
198 Views
Last Modified: 2013-12-17
I currently use this when one of  my dropdowns hasnt be selected. Now I need to be able to stop the user from submitting a request if the attachment hasnt been attached and the path is still visible in the uploader. I was going for an onlick if uploader is not blank then msgbox popup. The problem is I dont know how to reference the uploader. .Text .Value or another way? This is my attempt...

All help much appreciated
btnSubmit.Attributes.Add("onclick", "if(document.getElementById('FileUploadControl').text!='') {window.alert('Please submit your attachment before submitting request');return false;}");

Open in new window

0
Comment
Question by:dwezil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 22700890
Hello dwezil,

It is the .value property, however there is no guarantee that this will actually work. In IE it does if you allow active scripting that IE7 blocks. In firefox it doesn't seem to work at all. The reason for this is that access to that control is strictly controlled, in theory you should have no access to it (certainly no ability to write a value in there) and as I say there is no guarantee that client-side script will be able to access the .value property correctly on all browsers.

Regards,

TimCottee
0
 

Author Comment

by:dwezil
ID: 22700911
well could i possibly create a text box that mirrors the text in the uploader and set the msgbox to react to whether that text box has text or not?
0
 
LVL 43

Assisted Solution

by:TimCottee
TimCottee earned 500 total points
ID: 22700921
dwezil,

On the same basis, if you cannot access the property then you cannot mirror it. This is a case where your only recourse is to handle this in server-side validation rather than client-side.

TimCottee
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

Author Comment

by:dwezil
ID: 22700927
thats annoying, I thought it would have been a simple thing to do
0
 
LVL 43

Assisted Solution

by:TimCottee
TimCottee earned 500 total points
ID: 22700933
dwezil,

Indeed, it is a security thing though. Because that control is allowed access to the client's file system it poses a security risk as such it has been "locked down" in such a way to prevent any access to it with script. There is an obvious reason for this, if you could access that value easily and change it to a specific file you would then be able to silently upload any file from the client's machine to your server thus potentially compromising any system that viewed your page.

I understand the problem though and it is one that afflicts all of us.

TimCottee
0
 

Author Comment

by:dwezil
ID: 22700960
not even FileUploadControl.HasFile. Im clutching at straws here
0
 
LVL 43

Assisted Solution

by:TimCottee
TimCottee earned 500 total points
ID: 22701022
dwezil,

Server-side that is, and there it is no problem at all. It is simply the ability to interact with the control on the client-side that is severely restricted for security purposes. Once a user has selected a file and submitted the form then you can use .Hasfile etc in your server-side code quite happily. Of course the only problem with that is that you cannot prepopulate the fileupload element with the previously selected file name if it fails validation and is returned to the client.

TimCottee
0
 

Author Closing Comment

by:dwezil
ID: 31505552
Thanks for your help Tim
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
transition to visual .net from vb6 5 63
Groupbox Control ? 2 29
Google Maps with Webforms 1 29
c#, case, if 4 22
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question