SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the follwing code


            type: "POST",
            url: "/_Catalogs/MasterPage/GDetail.aspx/GetFundURL",

            data: "{'cusip': '" +$('#<%= ddlShareClasses.ClientID %>').val() + "'}",

            contentType: "application/json; charset=utf-8",

            dataType: "json",

            success: function (message) {


            }, error: function (message) {


Bloew is my Label

<asp:Label id="sample" runat="server"/`>

I want to bind message.d to label. with above code i can message have some url in alert but i am unable bind it

note: message.d is a hyperlink

share|improve this question
up vote 1 down vote accepted

Assuming that everything else is working and you get a valid JSON response, your success handler needs to be tweaked a bit. Because your label is a server-side control its id on the client will not be "sample." As a result, your jQuery selector will fail to select your label in the DOM. The selector should be something like this:

$('#<%= this.sample.ClientID %>');
share|improve this answer
Its not working thanks anyways – raky Dec 27 '12 at 19:43
Which part, the service call itself or the setting of the label tag's HTML? – nsturdivant Dec 27 '12 at 21:11
setting of the label. I can see the output in alert but i want to attach output to a label. when ever dropdown changes label value need to changed – raky Dec 27 '12 at 21:33
What is the output in the alert when you alert on message.d? Also, test your label selector by checking the length of the resulting jQuery object: alert($('#<%= this.sample.ClientID %>').length); We need to figure out if it's your selector or something to do with the value of message.d. – nsturdivant Dec 27 '12 at 21:39
$("#<%=lbKiidsUrl.ClientID%>").html(message.d.find("span:first").attr("onclick", "void(0)").addClass('confirmleave')); i did above code but confirm leave script is not calling when i clicked on label? can you please tell me what i am doing wrong here – raky Dec 31 '12 at 16:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.