How to get Client ID of div tag in asp.net
-
Hello All, I want to get ClientID of Div tag in javascript so can you please help me for that? i have declare div with runat="server". -------- Javascript ----- var divId = document.getElementById('<%=Parent.ClientID%>'); but divId returns null So can you please help me how i want to get clientID of div? Thanks in Advance.
Anish Patel
-
Hello All, I want to get ClientID of Div tag in javascript so can you please help me for that? i have declare div with runat="server". -------- Javascript ----- var divId = document.getElementById('<%=Parent.ClientID%>'); but divId returns null So can you please help me how i want to get clientID of div? Thanks in Advance.
Anish Patel
anish27patel wrote:
var divId = document.getElementById('<% = Parent.ClientID %>');
anish27patel wrote:
i want to get clientID of div?
Just simply use
var divId = document.getElementById('YourDivID');
You need ClienID for Server Side control. And i believe your div is in your client side .
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net View My Recent Article
-
Hello All, I want to get ClientID of Div tag in javascript so can you please help me for that? i have declare div with runat="server". -------- Javascript ----- var divId = document.getElementById('<%=Parent.ClientID%>'); but divId returns null So can you please help me how i want to get clientID of div? Thanks in Advance.
Anish Patel
anish27patel wrote:
<%=Parent.ClientID%>
What is parent? Parent should be the ID of Div and should be runat=server.Is it so?
Cheers!! Brij Check My Latest Article
-
anish27patel wrote:
<%=Parent.ClientID%>
What is parent? Parent should be the ID of Div and should be runat=server.Is it so?
Cheers!! Brij Check My Latest Article
Thanks for your response Yes parent is id of div and i have given runat="server" with div tag for your information my script in common place like inside .js file and if i want to write same statement in page i get that ClientId so can you please help me out how can i get div client id in common js?
Anish Patel
-
anish27patel wrote:
var divId = document.getElementById('<% = Parent.ClientID %>');
anish27patel wrote:
i want to get clientID of div?
Just simply use
var divId = document.getElementById('YourDivID');
You need ClienID for Server Side control. And i believe your div is in your client side .
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net View My Recent Article
Thanks for quick response but it's also return null can you please help me out ? for your more information my script in common palce like inside .js file Thanks
Anish Patel
-
Hello All, I want to get ClientID of Div tag in javascript so can you please help me for that? i have declare div with runat="server". -------- Javascript ----- var divId = document.getElementById('<%=Parent.ClientID%>'); but divId returns null So can you please help me how i want to get clientID of div? Thanks in Advance.
Anish Patel
anish27patel wrote:
var divId = document.getElementById('<%=Parent.ClientID%>');
Where is the above code written? In the external JS file? If yes, it is not gonna work. You need move this to your page, get the client id and pass to your JS method which may be in external file. :)
Navaneeth How to use google | Ask smart questions
-
Hello All, I want to get ClientID of Div tag in javascript so can you please help me for that? i have declare div with runat="server". -------- Javascript ----- var divId = document.getElementById('<%=Parent.ClientID%>'); but divId returns null So can you please help me how i want to get clientID of div? Thanks in Advance.
Anish Patel
You cannot use server side code like document.getElementById('<%=Parent.ClientID%>'); in your external .js file. Declare a global variable in your page and store the id of div tag in it. Then refer this variable in the .js file to get the client id. Declare this variable in your page: var yourDivId = '<%=Parent.ClientID%>'; Write this code in the .js file to get the above div id var objDiv = document.getElementById(yourDivId);
-
Thanks for your response Yes parent is id of div and i have given runat="server" with div tag for your information my script in common place like inside .js file and if i want to write same statement in page i get that ClientId so can you please help me out how can i get div client id in common js?
Anish Patel
Are you the clientID of your div. Try this First assign the clientid in javascript variable like var hdnCtlSelectedItem = "<%=Parent.ClientID%>"; then check whether the you are getting the clientid.and pass this ID to javascript function i external JS file Afterthat access the divid using document.getElementById(hdnCtlSelectedItem);
Cheers!! Brij Check My Latest Article