Literal control using javascript
Access Literal control using javascript:
IN Asp.net Programming web application development many time we want to get control on client site ,some time we want this for validation also. In javaScript Programming we can
Access html tag by tag id.then we can find literal by control id when need to access by javascript.
How to find literal control using javascript:
Means if we want to change any type in html tag properties. As like if you want to change text, change color, back-color etc then you easily changes by javascript. When we considering Many Questions related to this on internet then we get that some peoples face problems to access the ASP.net Literal control.
Here In this Post we that how to
Access Asp.net Literal control by javascript. As we know that we can Access
(This is my personal Experience in programming) Html tag by the javascript if
we want to Access these html controls or tags.
Declare variable in JS :
Var [variable_name] =
document.getElementById('<%= Control.ClientID
%>');
Access Control by ID in JS :
Here Var is Data_Type in javascript, And
Control.ClientID is the Id of that control which you want to
Access.
But we can’t
use this for Literal,
Var [var_literal] =
document.getElementById('<%=
Literal Control ID%>');
This is
Wrong way. because <asp:Literal> does not create their own Html tag. But
Other Asp.net Controls can create own html tag. So if you want to Access
literal control then define literal control in to other html tag like within
the <div> or <span>.
<span id="yourId"><asp:Literal ID="lblPerInstanceListing" runat="server"></asp:Literal>
Other Post Related to JScript:
Reference :
- Want to access literal value into javascript
- How to access control in javascript
- asp.net - Set ASP Literal text with Javascript
- Write text to literal control Javascript
- How To Access Literal Control In Javascript
- ASP.NET Literal Control
- Using jQuery change Background color of DIV
- JQuery Change Div Background Color Randomly
- JQuery Change Div Background Color Randomly
- C# Variables,How to declare in C#:
- C# language Program Structure
- What keyword,How many keywords in C#