Set value using jquery.

If Multiple user control on the same page. then if we need to Set value of the control using jquery. The following jquery function find the control by html tag and cssclass and set the value of the control.

Some time there is a situation where user can create the multiple user control on single page. The user controls have the pop up control from where user can select the employee. Now the pop up control have the label control. Now user need to change the text/label of the header control of the pop up control. at that time the aspx page render the last user control text. Then if am write the JavaScript function for set the value of the label by using getelementbyId then I not able to find the id of the label.

I need to write jquery for set the text of the pop up control header. By finding the class of that label

<script language="javascript" type="text/javascript">

function ChangePopUpHeader(headerString)
$('span.popupheader').each( function() {

The above jquery is first find the span control having ".popupheader" css class. and set the value of the header.

In .Cs file of the pop up page i can call above function using

ScriptManager.RegisterStartupScript(this, this.GetType(), "onclick", "window.parent.parent.parent.parent.window.ChangePopUpHeader('Book Appointment');", true);


Author: abhishek12 Jan 2012 Member Level: Silver   Points : 0

Good article..

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: