代码的想法是制作一个单独的文本框和按钮,这样我就可以为每一个创建类并让它们像文件上传一样工作。
但是 javascript 运行了两次,并且 fileupload 值被删除了。
<style type="text/css">
div.fileinputs
{
position: relative;
}
div.fakefile
{
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
}
input.file
{
visibility:hidden;
}
</style>
<script type="text/javascript" language="javascript">
function uploadFileChange() {
alert("start");
document.getElementById('FileName').value = document.getElementById("FileUpload1").value;
alert("end");
}
</script>
<div class="fileinputs" style="width: 50%;">
<!-- Upload file invisivel-->
<asp:FileUpload ID="FileUpload1" ClientIDMode="Static" class="file" runat="server"
onpropertychange="uploadFileChange();" />
<!-- button e textbox falsas para poder dar syles ao button-->
<div class="fakefile">
<asp:TextBox ID="FileName" CssClass="textbox" ClientIDMode="Static" runat="server" Width="31%" ></asp:TextBox>
<asp:Button ID="FileChooserButton1" CssClass="btnSubmit" runat="server" Text="Procurar..."
ForeColor="White" onClick="document.getElementeByID('FileUpload1').click()" />
</div>
</div>
怎么了???提前致谢