开发者

Finding ID FileUpload in javascript

开发者 https://www.devze.com 2023-02-10 03:45 出处:网络
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.

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

精彩评论

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