I have several aspx pages and one site.master. I defined *.js file with any javascript functions. And now I want to find ID of FileUpload control on one of this subpage.
f开发者_JS百科unction CheckFile()
{
var filePath = document.getElementById('<%= this.fileUp.ClientID %>').value;
but it doesn't work.
You can only use server-side code in ASPX pages, not standalone .js
files
Instead, you should pass the control's ID from inline Javascript in your ASPX.
try replace $ with _ in the id.
var filePath = document.getElementById('<%= this.fileUp.ClientID.ToString().Replace("$","_") %>').value;
精彩评论