I've have created a simpleModal popup. I want to return a value from a text input on the popup to a asp textbox on the parent page.
I have read all of the examples that are similar to this one, but none have answered my question.
My popup is a simple aspx page with a text input. Here is the code:
JavaScript
$(document).ready(function() {
$("a#lookup").click(function () {
//Load the Lookup page as a modal popup..
$.modal('<iframe src="TestPopup.aspx" height="200" width="450" style="border:5">', {
onOpen: function (dialog) {
dialog.overlay.fadeIn('slow', function () {
dialog.container.slideDown('100', function () {
dialog.data.fadeIn('fast');
});
});
},
preventDefault: true,
containerCss: {
backgroundColor: "#fff",
borderColor: "#aaa",
height: 530,
padding: 5,
width: 880,
escClose: false
},
closeHTML: "<a href='#'>Close</a>",
appendTo: 'form',
persist: true,
overlayClose: true,
onClose: function (dialog) {
var result = dialog.data.find("#msgText").val();
$('#txtLookupReturn').attr('value', result);
dialog.data.fadeOut('200', function () {
dialog.container.slideUp('200', function () {
dialog.overlay.fadeOut('200', function () {
$.modal.close();
});
});
});
}
});
});
});
TestPopup.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestPopup.aspx.cs" Inherits="WebServicesTest.TestPopup" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">;
<html xmlns="w3.org/1999/xhtml">;
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="msgText" type="text" value="I love jQuery!" />
</div>
</form>
</body>
</html>
This is the line of code that is not working:
var result = dialog.data.find("#msgText").val();
$('#txtLookupReturn').attr('value', result);
When I try to grab the value of #msgText
, I get no error and no value.
Appreciate any help!