PC Review


Reply
Thread Tools Rate Thread

Resetting the value of a System.Web.UI.HtmlControls.HtmlInputFile

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      22nd May 2006
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 submitted. However, ASP.NET
does not let you change the Value property of an HtmlInputFile control. How
can I reset the HtmlInputFile control to it's original state? Thanks.
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      22nd May 2006
Nathan,

A HTML control is not an ASPNET control. If it had extentions to handle it
in a better way, than it would be an ASPNET control.

Therefore handling an HTML control is as it could be done forever in HTML.
In my opinion is than the way to search for it on Google, but than not in
relation to DotNet but just as HTML control.

Cor

"Nathan Sokalski" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
>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 submitted. However, ASP.NET
>does not let you change the Value property of an HtmlInputFile control. How
>can I reset the HtmlInputFile control to it's original state? Thanks.
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>



 
Reply With Quote
 
=?Utf-8?B?RGVlcHNvbiBUaG9tYXM=?=
Guest
Posts: n/a
 
      22nd May 2006
Hi,
What you mean by reseting ?? is it means that you need to clear the value
from the control after the postback ??
--
Deepson Thomas


"Nathan Sokalski" wrote:

> 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 submitted. However, ASP.NET
> does not let you change the Value property of an HtmlInputFile control. How
> can I reset the HtmlInputFile control to it's original state? Thanks.
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>
>
>

 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      22nd May 2006
I think that there is an important lesson you should learn about how ASP.NET
handles controls. Any time you add runat="server" and an ID attribute to a
control, whether it is an html control or an ASP.NET webcontrol or any other
kind of control, if it is declared ASP.NET will treat it as an object (not
necessarily with extensions, it might just be an HtmlGenericControl). But
ASP.NET does have a class for the input type="file" control, which is
System.Web.UI.HtmlControls.HtmlInputFile One of the properties of this
control is Value. The Value property is not labeled as ReadOnly, but when
ASP.NET runs into the code where I assign a value to it while my Application
is running, it gives me an error saying I cannot change the Value property.
If I remember correctly, the same thing happens in JavaScript (although it's
been a while since I tried that). I may not have explained every detail with
textbook clarity here, but the important thing is that from ASP.NET's view
in my code, it is an ASP.NET control.
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/

"Cor Ligthert [MVP]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Nathan,
>
> A HTML control is not an ASPNET control. If it had extentions to handle it
> in a better way, than it would be an ASPNET control.
>
> Therefore handling an HTML control is as it could be done forever in HTML.
> In my opinion is than the way to search for it on Google, but than not in
> relation to DotNet but just as HTML control.
>
> Cor
>
> "Nathan Sokalski" <(E-Mail Removed)> schreef in bericht
> news:(E-Mail Removed)...
>>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 submitted. However,
>>ASP.NET does not let you change the Value property of an HtmlInputFile
>>control. How can I reset the HtmlInputFile control to it's original state?
>>Thanks.
>> --
>> Nathan Sokalski
>> (E-Mail Removed)
>> http://www.nathansokalski.com/
>>

>
>



 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      22nd May 2006
Yes, if the control continues to display the file path after I upload it,
many users will be inclined to think the upload was unsuccessful (even
though they will be able to see it in a list on the page). But I also want
it to be cleared so that the validator control I use to check that they
selected a file is useful.
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/

"Deepson Thomas" <(E-Mail Removed)> wrote in message
news:AB6B9CB5-C3AC-4F6E-8F47-(E-Mail Removed)...
> Hi,
> What you mean by reseting ?? is it means that you need to clear the value
> from the control after the postback ??
> --
> Deepson Thomas
>
>
> "Nathan Sokalski" wrote:
>
>> 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 submitted. However, ASP.NET
>> does not let you change the Value property of an HtmlInputFile control.
>> How
>> can I reset the HtmlInputFile control to it's original state? Thanks.
>> --
>> Nathan Sokalski
>> (E-Mail Removed)
>> http://www.nathansokalski.com/
>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?Y2luZHk=?=
Guest
Posts: n/a
 
      23rd May 2006
I am also having difficultly with the htmlinput file control I have a script
to validate the entry if the validation fails I need to return to the form
with htmlinputfile value still selected in the input box. The validation is
actually failing because of the file description that is entered into another
field on the form.

I AM SORRY COR to post in this thread but MS does use the HTMLINPUTFILE in
documentation and I have not had luck in GOOGLE.

Do you think you could tell us where to post this question instead of here?
--
cindy


"Cor Ligthert [MVP]" wrote:

> Nathan,
>
> A HTML control is not an ASPNET control. If it had extentions to handle it
> in a better way, than it would be an ASPNET control.
>
> Therefore handling an HTML control is as it could be done forever in HTML.
> In my opinion is than the way to search for it on Google, but than not in
> relation to DotNet but just as HTML control.
>
> Cor
>
> "Nathan Sokalski" <(E-Mail Removed)> schreef in bericht
> news:(E-Mail Removed)...
> >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 submitted. However, ASP.NET
> >does not let you change the Value property of an HtmlInputFile control. How
> >can I reset the HtmlInputFile control to it's original state? Thanks.
> > --
> > Nathan Sokalski
> > (E-Mail Removed)
> > http://www.nathansokalski.com/
> >

>
>
>

 
Reply With Quote
 
Gaurav Vaish \(EduJini.IN\)
Guest
Posts: n/a
 
      23rd May 2006
Haven't thoroughly looked at your code, but you may probably want to do the
following:

object SaveViewState()
{
object[] data = new object[2];
data[0] = base.SaveViewState();
date[1] = hash;

return data;
}

LoadViewState(object obj)
{
if(obj != null && obj is object[])
{
object[] data = (object[]) obj;
base.LoadViewState(data[0]);
Hashtable hash = (Hashtable) data[1];
<<Populate from the hash>>
}
}

--
Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.org
http://www.edujini.in
-------------------


"cindy" <(E-Mail Removed)> wrote in message
news:F76F6FB9-316C-4C64-8FF1-(E-Mail Removed)...
>I am also having difficultly with the htmlinput file control I have a
>script
> to validate the entry if the validation fails I need to return to the form
> with htmlinputfile value still selected in the input box. The validation
> is
> actually failing because of the file description that is entered into
> another
> field on the form.
>
> I AM SORRY COR to post in this thread but MS does use the HTMLINPUTFILE in
> documentation and I have not had luck in GOOGLE.
>
> Do you think you could tell us where to post this question instead of
> here?
> --
> cindy
>
>
> "Cor Ligthert [MVP]" wrote:
>
>> Nathan,
>>
>> A HTML control is not an ASPNET control. If it had extentions to handle
>> it
>> in a better way, than it would be an ASPNET control.
>>
>> Therefore handling an HTML control is as it could be done forever in
>> HTML.
>> In my opinion is than the way to search for it on Google, but than not in
>> relation to DotNet but just as HTML control.
>>
>> Cor
>>
>> "Nathan Sokalski" <(E-Mail Removed)> schreef in bericht
>> news:(E-Mail Removed)...
>> >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 submitted. However, ASP.NET
>> >does not let you change the Value property of an HtmlInputFile control.
>> >How
>> >can I reset the HtmlInputFile control to it's original state? Thanks.
>> > --
>> > Nathan Sokalski
>> > (E-Mail Removed)
>> > http://www.nathansokalski.com/
>> >

>>
>>
>>



 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      23rd May 2006
Cindy,

This is for me always the first start to problems with HTML controls. And
this special with the input file one.

http://msdn.microsoft.com/library/de...input_file.asp

This can be handled with javascript.

In VB.Net the javascript can be used with register.......... Be aware that
this have different implementations in version 1.x and 2.0

Cor


"cindy" <(E-Mail Removed)> schreef in bericht
news:F76F6FB9-316C-4C64-8FF1-(E-Mail Removed)...
>I am also having difficultly with the htmlinput file control I have a
>script
> to validate the entry if the validation fails I need to return to the form
> with htmlinputfile value still selected in the input box. The validation
> is
> actually failing because of the file description that is entered into
> another
> field on the form.
>
> I AM SORRY COR to post in this thread but MS does use the HTMLINPUTFILE in
> documentation and I have not had luck in GOOGLE.
>
> Do you think you could tell us where to post this question instead of
> here?
> --
> cindy
>
>
> "Cor Ligthert [MVP]" wrote:
>
>> Nathan,
>>
>> A HTML control is not an ASPNET control. If it had extentions to handle
>> it
>> in a better way, than it would be an ASPNET control.
>>
>> Therefore handling an HTML control is as it could be done forever in
>> HTML.
>> In my opinion is than the way to search for it on Google, but than not in
>> relation to DotNet but just as HTML control.
>>
>> Cor
>>
>> "Nathan Sokalski" <(E-Mail Removed)> schreef in bericht
>> news:(E-Mail Removed)...
>> >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 submitted. However, ASP.NET
>> >does not let you change the Value property of an HtmlInputFile control.
>> >How
>> >can I reset the HtmlInputFile control to it's original state? Thanks.
>> > --
>> > Nathan Sokalski
>> > (E-Mail Removed)
>> > http://www.nathansokalski.com/
>> >

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?Y2luZHk=?=
Guest
Posts: n/a
 
      23rd May 2006
I am new to c# I just want to inherit from htmlinputfile control and override
default LoadPostData always returns
false I want it to return true it is not security violation because the
Value property is readonly. The user then does not have to reselect the file
to try upload again. 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 I found this but I don't know enough where to start
.............
these controls do not save their viewstate. LoadPostData always returns
false. You can inherit from the class and
override LoadPostData to return true and try to restore the value, and still
have value readonly.
I am new to c# and asp net controls. is there example to inherit from
HtmlInputFile class and override LoadPostData to
return true I am using C# and this is challenging me bad. cindy





--
cindy


"Cor Ligthert [MVP]" wrote:

> Cindy,
>
> This is for me always the first start to problems with HTML controls. And
> this special with the input file one.
>
> http://msdn.microsoft.com/library/de...input_file.asp
>
> This can be handled with javascript.
>
> In VB.Net the javascript can be used with register.......... Be aware that
> this have different implementations in version 1.x and 2.0
>
> Cor
>
>
> "cindy" <(E-Mail Removed)> schreef in bericht
> news:F76F6FB9-316C-4C64-8FF1-(E-Mail Removed)...
> >I am also having difficultly with the htmlinput file control I have a
> >script
> > to validate the entry if the validation fails I need to return to the form
> > with htmlinputfile value still selected in the input box. The validation
> > is
> > actually failing because of the file description that is entered into
> > another
> > field on the form.
> >
> > I AM SORRY COR to post in this thread but MS does use the HTMLINPUTFILE in
> > documentation and I have not had luck in GOOGLE.
> >
> > Do you think you could tell us where to post this question instead of
> > here?
> > --
> > cindy
> >
> >
> > "Cor Ligthert [MVP]" wrote:
> >
> >> Nathan,
> >>
> >> A HTML control is not an ASPNET control. If it had extentions to handle
> >> it
> >> in a better way, than it would be an ASPNET control.
> >>
> >> Therefore handling an HTML control is as it could be done forever in
> >> HTML.
> >> In my opinion is than the way to search for it on Google, but than not in
> >> relation to DotNet but just as HTML control.
> >>
> >> Cor
> >>
> >> "Nathan Sokalski" <(E-Mail Removed)> schreef in bericht
> >> news:(E-Mail Removed)...
> >> >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 submitted. However, ASP.NET
> >> >does not let you change the Value property of an HtmlInputFile control.
> >> >How
> >> >can I reset the HtmlInputFile control to it's original state? Thanks.
> >> > --
> >> > Nathan Sokalski
> >> > (E-Mail Removed)
> >> > http://www.nathansokalski.com/
> >> >
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HtmlControls.HtmlInputFile - do I have to have a separate upload button? gazza@3inabed.com Microsoft ASP .NET 0 11th Sep 2006 05:20 PM
Resetting the value of a System.Web.UI.HtmlControls.HtmlInputFile Nathan Sokalski Microsoft ASP .NET 8 23rd May 2006 11:21 PM
System.Web.UI.HtmlControls.HtmlInputFile =?Utf-8?B?TWF0cml4IC0gTUFN?= Microsoft Dot NET 0 29th Nov 2004 08:45 PM
Please Help With Error: c:\inetpub\wwwroot\admin\filemanager.aspx.vb(76): Expression is of type 'System.Web.UI.HtmlControls.HtmlInputFile', which is not a collection type. Sean Carey Microsoft VB .NET 2 20th Apr 2004 04:46 PM
System.Web.UI.HtmlControls.HtmlInputFile szabelin Microsoft ASP .NET 0 5th Aug 2003 12:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:10 PM.