N
nes
Hi all,
For uploading files i am using the HtmlInputFile. Now I want to do
things with it. First I want to give the button a specific style an
second when a postback happens I don't want the selected file t
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 htmlInputfil
but separate button and textbox so you can give your style and you hav
the file name showing.
My problem is that I have an ASP:BUTTON for Submitting my file (som
reading, changing, ...) But when you click the button for the firs
time it erases the value from the HtmlInputFile. So you have to pres
again for really doing your submit code.
You don't have that problem when you are using a HtmlInputButton(if yo
use clientscript), but unfortunately I can't use it.
Has anyone got a suggestion how I can resolve the problem of have t
press the button twice?
Thx
Ne
For uploading files i am using the HtmlInputFile. Now I want to do
things with it. First I want to give the button a specific style an
second when a postback happens I don't want the selected file t
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 htmlInputfil
but separate button and textbox so you can give your style and you hav
the file name showing.
My problem is that I have an ASP:BUTTON for Submitting my file (som
reading, changing, ...) But when you click the button for the firs
time it erases the value from the HtmlInputFile. So you have to pres
again for really doing your submit code.
You don't have that problem when you are using a HtmlInputButton(if yo
use clientscript), but unfortunately I can't use it.
Has anyone got a suggestion how I can resolve the problem of have t
press the button twice?
Thx
Ne