Is it possible to write a javascript function which can get element by its 'id'
i tried to use this function
function getEleById(ele,IsServerElemt) {
var elmt ;
if(IsServerElemt)
elmt = '<%='+ ele + '.ClientID%>' ;
else
elmt = ele;
return document.getElementById(elmt);
}
Here we have HTML as well as Asp.Net TextBox.
<input type="text" id="txtname" />
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
and iam trying to call the function as follows
var name = getEleById('txtname',true) ;
here true specifies that txtname is server control
Is it possible to have a generic javascript method for HTML as well Asp.Net controls.
Any help would be appreciated.
Thanks
elein this context? Is it a string? A control? You definitely can't mix client side and server side scripting the way you have here. This flat out will not compile properly.