Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a branch.js file, in this i am going to write like this
C#
  function BSC_ShowControl()
{
     var ele = document.getElementById("BSC_FullScreen");
      ele.style.zIndex = 1000 - 1;
}

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...
Posted
Updated 9-Mar-11 0:46am
v2
Comments
Albin Abel 9-Mar-11 6:58am    
Are you having this script in the master page? If not put it in master page

1 solution

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 %>');
 
Share this answer
 
Comments
Sridhar Patnayak 10-Mar-11 7:29am    
Yh thanks, i got it
I didn't add BranchSearch.ascx(user control) to the aspx page
Sandeep Mewara 10-Mar-11 9:06am    
Then my answer should surely help. Try out.

Great!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900