Hi all,
For uploading files i am using the HtmlInputFile. Now I want to do 2
things with it. First I want to give the button a specific style and
second when a postback happens I don't want the selected file to
disappear from the HtmlInputFile.
Now on the web I found the next thing:
<html>
<head>
<title>File Upload Example</title>
<script language="JavaScript" type="text/javascript">
function HandleFileButtonClick()
{
document.frmUpload.myFile.click();
document.frmUpload.txtFakeText.value =
document.frmUpload.myFile.value;
}
</script>
</head>
<body>
<form name="frmUpload">
<!-- Real Input field, but hidden-->
<input type="file" name="myFile" style="display: none">
<!-- Fake field to fool the user -->
<input type="text" name="txtFakeText" readonly="true">
<!-- Button to invoke the click of the File Input -->
<input type="button" onclick="HandleFileButtonClick();"
value="Upload File" style="background: red;">
</form>
</body>
</html>
Now this works really perfect. You don't really use the htmlInputfile
but separate button and textbox so you can give your style and you have
the file name showing.
My problem is that I have an ASP:BUTTON for Submitting my file (some
reading, changing, ...) But when you click the button for the first
time it erases the value from the HtmlInputFile. So you have to press
again for really doing your submit code.
You don't have that problem when you are using a HtmlInputButton(if you
use clientscript), but unfortunately I can't use it.
Has anyone got a suggestion how I can resolve the problem of have to
press the button twice?
Thx
Nes
--
nes
------------------------------------------------------------------------
nes's Profile:
http://www.highdots.com/forums/m1723
View this thread:
http://www.highdots.com/forums/t3198457