Home All Groups Group Topic Archive Search About

post-back when the filename to upload changes

Author
19 Mar 2006 10:05 PM
David Thielen
Hi;

Is there a way to do this? I want to get a post-back if the file to be
uploaded changes. I am thinking if I have a javascript variable with the
string in the filename text box. And then a javascript function is called
when leaving the filename textbox or when the browse button places a new
filename in the textbox – the javascript then does a post-back if the text
content has changed. Would this work? And do you think it is a good way to
handle this? What I show on the page depends on the content of that uploaded
file.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Author
20 Mar 2006 12:39 AM
Axel Dahmen
You might get answers to this in a JavaScript newsgroup.

Axel Dahmen

--------
Show quoteHide quote
"David Thielen" <thielen@nospam.nospam> schrieb im Newsbeitrag
news:63D7F5EF-B662-41DA-BD77-FC4A9A1D4F37@microsoft.com...
> Hi;
>
> Is there a way to do this? I want to get a post-back if the file to be
> uploaded changes. I am thinking if I have a javascript variable with the
> string in the filename text box. And then a javascript function is called
> when leaving the filename textbox or when the browse button places a new
> filename in the textbox - the javascript then does a post-back if the text
> content has changed. Would this work? And do you think it is a good way to
> handle this? What I show on the page depends on the content of that
uploaded
> file.
>
> --
> thanks - dave
> david_at_windward_dot_net
> http://www.windwardreports.com
>
Author
20 Mar 2006 8:58 AM
Steven Cheng[MSFT]
Hi Dave,

The ASP.NET 2.0 upload control actually encapsulate the html <input
type="file" name="file1" ..../> element. And if you want to do some thing
when the client user change the file to upload, you can register the
"onchange" client-side event of the input file element. e.g:

====================
................
<script language="javascript">
    function file_onchange(file)
    {
        alert(file.value);

        document.forms[0].submit();

    }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <input type="file" id="file1"  name="file1" runat="server" 
onchange="file_onchange(this);" />
.......................

======================

The above page use a script function to postback the page when the user
change the filename o the upload html element.

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)