Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Tuesday, July 29, 2014

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>.

Your Literal control is a placeholder for text or HTML you will set in your code behind. You should bind your literal in a DIV or SPAN and give that an ID and reference that DIV or SPAN in the JavaScript


<span id="yourId"><asp:Literal  ID="lblPerInstanceListing" runat="server"></asp:Literal>


Other Post Related to JScript:

Reference :
  1. Want to access literal value into javascript
  2. How to access  control in javascript
  3. asp.net - Set ASP Literal text with Javascript
  4. Write text to literal control  Javascript 
  5. How To Access Literal Control In Javascript
  6. ASP.NET Literal Control
  7. Using jQuery change Background color of DIV
  8. JQuery Change Div Background Color Randomly
  9. JQuery Change Div Background Color Randomly
  10. C# Variables,How to declare in C#:
  11. C# language Program Structure
  12. What keyword,How many keywords in C#



Refe