Java脚本不适用于Ascx页面 [英] Java script not working for ascx page
本文介绍了Java脚本不适用于Ascx页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个branch.js文件,在这里我要这样写
I have a branch.js file, in this i am going to write like this
function BSC_ShowControl()
{
var ele = document.getElementById("BSC_FullScreen");
ele.style.zIndex = 1000 - 1;
}
BSC_FullScreen是一个div BranchSearch.ascx分配有它
现在我正在从aspx.cs文件调用BSC_ShowControl()函数
问题是 ele 为空,因此出现错误
任何帮助...
BSC_FullScreen is a div BranchSearch.ascx is assigned with it
now i am calling BSC_ShowControl() function from aspx.cs file
Problem is ele is getting null, so that getting error
any help...
推荐答案
您必须使用母版页或用户控件.
服务器控件有时在呈现时会获得不同的控件ID.
两种选择:
1.在渲染的页面上,执行视图源.找到控件ID并在JS中使用该ID
或
2.在JS中使用如下代码:
You must be using master page or a user control.
Server controls while getting rendered at times gets a different control ID.
Two options:
1. On rendered page, do a view source. Find the control id and use that one in JS
OR
2. Use something like this in JS:
var ele = document.getElementById(''<%= BSC_FullScreen.ClientID %>'');
这篇关于Java脚本不适用于Ascx页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文