views:

26

answers:

2

I have searched already but unable to find an answer that works. I simply want to set the text of a label that is in a content page. Obviously because the control is in a content page it has the modified client id. So I know simply ".labelName" will not work alone because the client id is for example "ctl00_ContentPlaceHolder1_labelName".

So what is the syntax to use when the control is in a content page?

Here's what I have that is not working:

function intervalTypeChanged(sender, eventArgs) {

            var item = eventArgs.get_item();
            var itemText = item.get_text();
            if (itemText == "Seconds" || itemText == "Minutes" || itemText == "Hours") {
                $("#trSimpleScheduleSettings").show();                    
                $("#<%=lblSimpleDurationValueAfter.ClientID %>").text = itemText;
            }
            else {
                $("#trSimpleScheduleSettings").hide();
            }
        }

The table row trSimpleScheduleSettings appears but there is no text in the label.

+1  A: 

.text()

$("#<%=lblSimpleDurationValueAfter.ClientID %>").text(itemText);
Reigel
aaah of course, I'm so stupid (and new to jQuery).Thanks.
empo
Hey Reigel, sorry, but now that I have moved the code out into a .js file it has stopped working.
empo
it would not work because of `<%=lblSimpleDurationValueAfter.ClientID %>`....
Reigel
A: 

Apart from the plain text if you want to set the content of the label in the form of html like

 <b>Some Value</b>
In that case you can use

$("#<%=lblSimpleDurationValueAfter.ClientID %>").html(itemText);
Prakash Kalakoti
it's already obvious what `itemText` is... `if (itemText == "Seconds" || itemText == "Minutes" || itemText == "Hours")`
Reigel