views:

65

answers:

2

i have a page which uses some javascript code to run,it was working fine until i added it to master page, on adding it to master page it gives me an error from javascript

var fu1 = document.getElementById("FileUpload1");
 var ex1 = extension(fu1.value) ; object expected in fu1.value

i need to know where to add the javascript in master page

+2  A: 

Try this

var fu1 = document.getElementById("<%= FileUpload1.ClientID %>");
var ex1 = extension(fu1.value)
Anuraj
i have already tried this but is not working
sumit
What the error you are getting? Where is your script? Content Page or Master Page?
Anuraj
A: 

I'm guessing you have one of these controls:

<input id="FileUpload1" runat="server" type="file" />

If so, you can access it in Javascript like so:

var fu1 = document.getElementById('<%= FileUpload1.ClientID %>');

Don't forget the runat="server" on the control.

adrianos
you don't use <%# with variables or control ids. it is for databound stuff only.
TheVillageIdiot
Doh, the evils of copy and paste from your own code.
adrianos