473,396 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Programmatic access to HtmlInputFile value it is a runat server

I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use to
submit files. Before the file is successfully submitted I validate another
field on the form, it is the description of the file must be 500 characters.
I am adding the file to a site server library programmatically so if the
field is too long I want to return the user to the form with file still
selected in the HtmlInputFile control. I am using an error label to inform
the user to shorten the description. I do not want the user to have to
browse again to the same file after he has shortened the description. Right
now the file does not upload but the control is empty. ASP.NET does not let
me programmatically put the full filename and path back into the Value
property of the HtmlInputFile control. How can I do this? I have version
asp.net 1.1
If there is a better thread to post this in please tell me where. I have
searched on Google and cannot find anything. Can I “override” the value
property to add the set? Please help. Cindy

--
cindy
May 23 '06 #1
7 1599
I found this but I don't know enough where to start
.............
these controls do not save their viewstate. LoadPostData always returns
false, and the Value property is readonly. You can inherit from the class and
override LoadPostData to return true and try to restore the value, but value
is readonly.

Example to inherit from HtmlInputFile class and override LoadPostData to
return true I am using C# and this is challenging me bad. cindy
"cindy" wrote:
I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use to
submit files. Before the file is successfully submitted I validate another
field on the form, it is the description of the file must be 500 characters.
I am adding the file to a site server library programmatically so if the
field is too long I want to return the user to the form with file still
selected in the HtmlInputFile control. I am using an error label to inform
the user to shorten the description. I do not want the user to have to
browse again to the same file after he has shortened the description. Right
now the file does not upload but the control is empty. ASP.NET does not let
me programmatically put the full filename and path back into the Value
property of the HtmlInputFile control. How can I do this? I have version
asp.net 1.1
If there is a better thread to post this in please tell me where. I have
searched on Google and cannot find anything. Can I “override” the value
property to add the set? Please help. Cindy

--
cindy

May 23 '06 #2
This looks like a security issue here. you are not allowed to do this.
What happens if I pre-populate your email address book or some important
file on your machine and upload it.
Other options may be an activex, java, or .NET control. again they must be
trusted.

Sa
"cindy" <cm****@nospam.nospam> wrote in message
news:F2**********************************@microsof t.com...
I found this but I don't know enough where to start
............
these controls do not save their viewstate. LoadPostData always returns
false, and the Value property is readonly. You can inherit from the class
and
override LoadPostData to return true and try to restore the value, but
value
is readonly.

Example to inherit from HtmlInputFile class and override LoadPostData to
return true I am using C# and this is challenging me bad. cindy
"cindy" wrote:
I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use to
submit files. Before the file is successfully submitted I validate
another
field on the form, it is the description of the file must be 500
characters.
I am adding the file to a site server library programmatically so if the
field is too long I want to return the user to the form with file still
selected in the HtmlInputFile control. I am using an error label to
inform
the user to shorten the description. I do not want the user to have to
browse again to the same file after he has shortened the description.
Right
now the file does not upload but the control is empty. ASP.NET does not
let
me programmatically put the full filename and path back into the Value
property of the HtmlInputFile control. How can I do this? I have version
asp.net 1.1
If there is a better thread to post this in please tell me where. I have
searched on Google and cannot find anything. Can I "override" the value
property to add the set? Please help. Cindy

--
cindy

May 23 '06 #3
no not security violation I just want to reload original file so user does
not have to reselect to try upload again. I do not want to change readonly
of the value just the default behavior of LoadPostData to return false--
cindy
"msdn" wrote:
This looks like a security issue here. you are not allowed to do this.
What happens if I pre-populate your email address book or some important
file on your machine and upload it.
Other options may be an activex, java, or .NET control. again they must be
trusted.

Sa
"cindy" <cm****@nospam.nospam> wrote in message
news:F2**********************************@microsof t.com...
I found this but I don't know enough where to start
............
these controls do not save their viewstate. LoadPostData always returns
false, and the Value property is readonly. You can inherit from the class
and
override LoadPostData to return true and try to restore the value, but
value
is readonly.

Example to inherit from HtmlInputFile class and override LoadPostData to
return true I am using C# and this is challenging me bad. cindy
"cindy" wrote:
I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use to
submit files. Before the file is successfully submitted I validate
another
field on the form, it is the description of the file must be 500
characters.
I am adding the file to a site server library programmatically so if the
field is too long I want to return the user to the form with file still
selected in the HtmlInputFile control. I am using an error label to
inform
the user to shorten the description. I do not want the user to have to
browse again to the same file after he has shortened the description.
Right
now the file does not upload but the control is empty. ASP.NET does not
let
me programmatically put the full filename and path back into the Value
property of the HtmlInputFile control. How can I do this? I have version
asp.net 1.1
If there is a better thread to post this in please tell me where. I have
searched on Google and cannot find anything. Can I "override" the value
property to add the set? Please help. Cindy

--
cindy


May 23 '06 #4
If you can populate the File-Path then what prevents somebody else from
putting what ever they want in it and upload any file from the client
machine.
The limitations on the HtmlInputFile are for security reasons and by design,

You should punish the user for not following the rules and ask them to
select the file again. I know this is a hassle but life if tuff.
If you find a solution please let us know.

Otherwise deal with it using ActiveX, Java Applet, or DotNet Compontents
that need security permissions anyway to run on the client side.

I like to see the hack.

Sa
"cindy" <cm****@nospam.nospam> wrote in message
news:F0**********************************@microsof t.com...
no not security violation I just want to reload original file so user does
not have to reselect to try upload again. I do not want to change
readonly
of the value just the default behavior of LoadPostData to return false--
cindy
"msdn" wrote:
This looks like a security issue here. you are not allowed to do this.
What happens if I pre-populate your email address book or some important
file on your machine and upload it.
Other options may be an activex, java, or .NET control. again they must
be
trusted.

Sa
"cindy" <cm****@nospam.nospam> wrote in message
news:F2**********************************@microsof t.com...
>I found this but I don't know enough where to start
> ............
> these controls do not save their viewstate. LoadPostData always returns
> false, and the Value property is readonly. You can inherit from the
> class
> and
> override LoadPostData to return true and try to restore the value, but
> value
> is readonly.
>
> Example to inherit from HtmlInputFile class and override LoadPostData
> to
> return true I am using C# and this is challenging me bad. cindy
>
>
> "cindy" wrote:
>
>> I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use
>> to
>> submit files. Before the file is successfully submitted I validate
>> another
>> field on the form, it is the description of the file must be 500
>> characters.
>> I am adding the file to a site server library programmatically so if
>> the
>> field is too long I want to return the user to the form with file
>> still
>> selected in the HtmlInputFile control. I am using an error label to
>> inform
>> the user to shorten the description. I do not want the user to have
>> to
>> browse again to the same file after he has shortened the description.
>> Right
>> now the file does not upload but the control is empty. ASP.NET does
>> not
>> let
>> me programmatically put the full filename and path back into the Value
>> property of the HtmlInputFile control. How can I do this? I have
>> version
>> asp.net 1.1
>> If there is a better thread to post this in please tell me where. I
>> have
>> searched on Google and cannot find anything. Can I "override" the
>> value
>> property to add the set? Please help. Cindy
>>
>> --
>> cindy


May 23 '06 #5
One thought comes to mind,

Why not keep the file that has been uploaded already in a temporary place
and just get back from the user the shortened description.
Tell them you must shorten your description. After the description
satisfies the max length then you deal with the tempsaved file.

use a GUID or something to keep tack of the files and descriptions and
expire them also.

Sa

"msdn" <sq**********@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...
If you can populate the File-Path then what prevents somebody else from
putting what ever they want in it and upload any file from the client
machine.
The limitations on the HtmlInputFile are for security reasons and by
design,

You should punish the user for not following the rules and ask them to
select the file again. I know this is a hassle but life if tuff.
If you find a solution please let us know.

Otherwise deal with it using ActiveX, Java Applet, or DotNet Compontents
that need security permissions anyway to run on the client side.

I like to see the hack.

Sa
"cindy" <cm****@nospam.nospam> wrote in message
news:F0**********************************@microsof t.com...
no not security violation I just want to reload original file so user
does
not have to reselect to try upload again. I do not want to change
readonly
of the value just the default behavior of LoadPostData to return false--
cindy
"msdn" wrote:
This looks like a security issue here. you are not allowed to do this.
What happens if I pre-populate your email address book or some important
file on your machine and upload it.
Other options may be an activex, java, or .NET control. again they must
be
trusted.

Sa
"cindy" <cm****@nospam.nospam> wrote in message
news:F2**********************************@microsof t.com...
>I found this but I don't know enough where to start
> ............
> these controls do not save their viewstate. LoadPostData always
> returns
> false, and the Value property is readonly. You can inherit from the
> class
> and
> override LoadPostData to return true and try to restore the value, but
> value
> is readonly.
>
> Example to inherit from HtmlInputFile class and override LoadPostData
> to
> return true I am using C# and this is challenging me bad. cindy
>
>
> "cindy" wrote:
>
>> I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use
>> to
>> submit files. Before the file is successfully submitted I validate
>> another
>> field on the form, it is the description of the file must be 500
>> characters.
>> I am adding the file to a site server library programmatically so if
>> the
>> field is too long I want to return the user to the form with file
>> still
>> selected in the HtmlInputFile control. I am using an error label to
>> inform
>> the user to shorten the description. I do not want the user to have
>> to
>> browse again to the same file after he has shortened the description.
>> Right
>> now the file does not upload but the control is empty. ASP.NET does
>> not
>> let
>> me programmatically put the full filename and path back into the
>> Value
>> property of the HtmlInputFile control. How can I do this? I have
>> version
>> asp.net 1.1
>> If there is a better thread to post this in please tell me where. I
>> have
>> searched on Google and cannot find anything. Can I "override" the
>> value
>> property to add the set? Please help. Cindy
>>
>> --
>> cindy


May 23 '06 #6
Hi cindy,

Thank you for post.

The HtmlInputFile's content will be automatically cleared when the page is
posted. It's one of the controls that will not preserve values. And yes
it's due to security reason and by design.

Besides other community members' suggestions, I think you can check the
description field length in javascript before submitting the form, thus not
causing a postback.
Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

May 24 '06 #7
Walter, Good point.

Sa
"Walter Wang [MSFT]" <wa****@online.microsoft.com> wrote in message
news:gl**************@TK2MSFTNGXA01.phx.gbl...
Hi cindy,

Thank you for post.

The HtmlInputFile's content will be automatically cleared when the page is
posted. It's one of the controls that will not preserve values. And yes
it's due to security reason and by design.

Besides other community members' suggestions, I think you can check the
description field length in javascript before submitting the form, thus
not
causing a postback.
Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

May 24 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Al Smith | last post by:
Newbee to aspx needs direction. We are using an <INPUT type="file" tag to upload a file. We also have a text field for the user to enter a description for the file which the user must enter. ...
5
by: Ariel Dolan | last post by:
Can I use HtmlInputFile to only get the selected file name but not actually upload the file? Clicking the control's Browse button let's the user select a file. All I need is the HtmlInputFile...
5
by: Grant Harmeyer | last post by:
I have an application that uses FreeTextBox 2.0 (http://www.freetextbox.com). FreeTextBox is a rich text editor that behaves similarly to MS Word. The FreeTextBox control has a button to insert...
4
by: Chris | last post by:
I'm uploading files to a location on my server. It works fine accept, I can't seem to get the control over the max file size to upload and the types I want to only allow. Max file size = 50KB...
7
by: Buddy Ackerman | last post by:
I created this class Public Class HTMLFileInput : Inherits System.Web.UI.HtmlControls.HtmlInputFile Public Property Data As String Get Return ViewState("HTMLFileInput.Data") End Get Set...
13
by: Larry O via DotNetMonster.com | last post by:
Hi - I'm a newbie to .NET and I was hoping someone would be so kind as to help me out with a question? Specifiec in my .aspx file: <input type="file" size="50" id="FileToSend" runat="server"...
0
by: ian | last post by:
Hello, I have a small test.aspx page with an HtmlInputFile class instance and an imagebutton. When I run this on our proxy server and click the save imagebutton I get the "Page cannot be...
4
by: matt | last post by:
hello, i have a datagrid w/ a TemplateColumn in it, like so: <asp:TemplateColumn HeaderText="Select"> <ItemTemplate> <asp:CheckBox ID="chkSelected" Runat="server"/> </ItemTemplate>...
8
by: Nathan Sokalski | last post by:
I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use to submit files. After the file is successfully submitted, I want the field to be reset so that the user knows the file was...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.