Ahmed Gaber
Ahmed Gaber

Reputation: 708

asp.net get value from Jquery UI dialog back to first form

I have the below JQuery script

<script type="text/javascript">
     $(function() {
         $("#no-email-popup").dialog(
             {
                 autoOpen: false,
                 buttons: {
                     "ok": function() {
                     alert($('#new_email').val());
                     alert(window.top.$("#new_email_label.").val());
                   //  alert(window.top.$("#<%= new_email_label.ClientID %>").val());
                         $(this).dialog("close");

                     },
                     "cancel": function() {
                         $(this).dialog("close");
                     }
                 }

             }
        );
     });
</script>

And and modal asp.net is

<div id="no-email-popup">
<label>Enter Email: </label>
<input type="text" id="new_email" />
</div>  

I want to get the value from Pop up back to to asp.net page and assign to label there

<asp:Label ID="new_email_label" runat="server">test top window label</asp:Label>

I found out that I cannot change the value of this label even

Please help how to get value to top asp.net page

Upvotes: 2

Views: 942

Answers (2)

paul
paul

Reputation: 22001

after (or instead) of your alerts, try: $("#new_email_label").val($("#new_email").val());

Upvotes: 0

Allov
Allov

Reputation: 1328

Using .val() on a <label/> won't give you the inner html of said label. You would need to use .html() to retrieve it, or .html("something") to set it.

Upvotes: 1

Related Questions