Why we are using ClientID while using master page ?
-
if we want to take value in control through javascript we will use var ds = document.getElementById("dvMyDiv").value ; if we are using master page means var ds = document.getElementById("<%=dvMyDiv.ClientID %>").value ; Why we are using ClientID while using master page ?
-
if we want to take value in control through javascript we will use var ds = document.getElementById("dvMyDiv").value ; if we are using master page means var ds = document.getElementById("<%=dvMyDiv.ClientID %>").value ; Why we are using ClientID while using master page ?
-
if we want to take value in control through javascript we will use var ds = document.getElementById("dvMyDiv").value ; if we are using master page means var ds = document.getElementById("<%=dvMyDiv.ClientID %>").value ; Why we are using ClientID while using master page ?
Whenever you are using MasterPages, the master page can contain dvMyDiv into it. So if you call it with this name only, it will be calling the masterpage dvMyDiv. Generally after rendering the page, which is inside the masterpage, .NET prefix each control within the page with the masterpage placeholder name. Thus ambiguity could be removed by this. Thus from javascript if you want to find this control, you need to call the valid object, means contentplaceholdername_dvMyDiv. Otherwise you could replace the javascript call through the server tags with the appropriate client id. Check your view source, you will get the idea of what the id of the control looks like in your page.:rose:
Abhishek Sur
-
if we want to take value in control through javascript we will use var ds = document.getElementById("dvMyDiv").value ; if we are using master page means var ds = document.getElementById("<%=dvMyDiv.ClientID %>").value ; Why we are using ClientID while using master page ?
md_azy wrote:
Why we are using ClientID while using master page ?
Whenever a server control is inside a container control (like the Content control used by content pages), the id of the container is prepended to the id of the control to ensure that every id in the page is unique. So, it's not only when you have a master page.
Despite everything, the person most likely to be fooling you next is yourself.