Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have the follwing code

$.ajax({

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

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

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

            dataType: "json",

            success: function (message) {

                $("#sample").html(message.d);
                alert(message.d);

            }, error: function (message) {

                $("#sample").html(message.d);
            }
            });

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
add comment

1 Answer

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
show 8 more comments

Your Answer

 
discard

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.