Reputation: 138
When i start the page it gives me this error. I can press no but then the code doesnt work.
the code is how do i fix this error?? by the way the button browse opens the fileupload but that is in c# Thanks in advance.
<%@ control language="C#" autoeventwireup="true" inherits="Web_Controls_SOLATDFileChooser, App_Web_ivmyhbca" %>
<!--2012-05-11 TP : Redesign da página web -->
<link rel="stylesheet" type="text/css" href="../styles/CMM/InternetFace.css" />
<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 clear() {
document.getElementById("<%=FileUpload1.ClientID %>").value = "";
document.getElementById("<%=txtFileName.ClientID %>").value = "";
}
</script>
<script type="text/javascript" language="javascript">
function uploadFileChange() {
document.getElementById("<%=txtFileName.ClientID %>").value = document.getElementById("<%=FileUpload1.ClientID %>").value;
}
</script>
<table width="500px">
<tr>
<td valign="middle">
<div class="fileinputs">
<!-- Upload file invisivel-->
<asp:FileUpload ID="FileUpload1" class="file" runat="server"
onchange="uploadFileChange();" />
<!-- button e textbox falsas para poder dar syles-->
<div class="fakefile">
<!--textbox onde está o path do ficheiro-->
<asp:TextBox ID="txtFileName" CssClass="textbox" runat="server"
Width="300px" ReadOnly="true" />
<!-- button de browse-->
<asp:Button ID="btnBrowse" runat="server" Text="Procurar..."
ForeColor="White" Height="21px" />
<!--button para apagar o path ja que a textbox esta em read-only para prevenir erros-->
<asp:Button ID="btnCancel" Height="21px" CssClass="btnSubmit" Text="Apagar" ForeColor="White"
OnClientClick="clear();" runat="server" />
</div>
</div>
</td>
</tr>
</table>
Upvotes: 2
Views: 313
Reputation: 123397
you have many errors in that code
;
after {
(in both functions (before you updated)documente
instead of document
(before you updated)UploadFileChange
(you called it UploadFielChange
) (before you updated)getElementById()
and as a sidenote it's useless to close a script
block and then reopen another one on next line. Both the functions can be enclosed in the same script
block
Upvotes: 5
Reputation: 565
Remove the ";" after the opening brackets of the functions and replace "documente" with "document"
<script type="text/javascript" language="javascript">
function clear() {
document.getElementById(<%=FileUpload1.ClientID %>).value ="";
document.getElementById(<%=txtFileName.ClientID %>).value ="";
}
</script>
<script type="text/javascript" language="javascript">
function uploadFielChange() {
document.getElementById(<%=txtFileName.ClientID %>).value = document.getElementById(<%=FileUpload1.ClientID %>).value;
}
</script>
...
Upvotes: 1
Reputation: 41060
Obviously your server template engine does not work:
<%=FileUpload1.ClientID %>
is no valid JS. Check your code with http://www.jslint.com/!
Upvotes: 1
Reputation: 1346
Remove ;
after {
and change documente
to document
. Also, some quotations are missing:
<script type="text/javascript" language="javascript">
function clear() {
document.getElementById('<%=FileUpload1.ClientID %>').value ="";
document.getElementById('<%=txtFileName.ClientID %>').value ="";
}
</script>
<script type="text/javascript" language="javascript">
function uploadFielChange() {
document.getElementById('<%=txtFileName.ClientID %>').value = document.getElementById('<%=FileUpload1.ClientID %>').value;
}
</script>
And please notice that uploadFielChange
!= UploadFielChange
, so you got to change this as well.
Upvotes: 2
Reputation: 21542
"documente" is not correct, should be "document" instead
As well, maybe the interpreter has problems with the ";" right after "{", which is useless
Rgds.
Upvotes: 2
Reputation: 53331
You're using documente
throughout your code where I suspect you want document
. Try changing that first off.
You have an extra ;
at the end of this line: function uploadFielChange() {;
Finally, you need to quote the IDs, as Alex K. pointed out.
Upvotes: 1