开发者

Finding ID FileUpload in javascript

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜