Friday, February 20, 2009

jquery get and set value dealing with asp.net control

this demo show that how I get value from the lblSearchType (Label) and populate data into txtKeyword (TextBox) asp.net control when I click different radio button using jquery

$('#<%=rdKeywordSearch.ClientID%>').click(function() {
$('#<%=lblSearchType.ClientID%>').text("Keyword");
$('#<%=txtKeyword.ClientID%>_input').attr("value", "Keyword");
$('#<%=txtKeyword.ClientID%>_input').attr("value", "Enter keyword here...");
});

$('#<%=rdLocationSearch.ClientID%>').click(function() {
$('#<%=lblSearchType.ClientID%>').text("Location");
$('#<%=txtKeyword.ClientID%>_input').attr("value", "Location");
$('#<%=txtKeyword.ClientID%>_input').attr("value", "Enter location here...");
});

3 comments:

Anonymous said...

Where are you getting the value of the label?

Carso Leong said...

all you need to do is to drag a asp.net control and name it.

Anonymous said...

uh... amazing thread :)