如何将 jQuery 对话框中元素的选定值传递到其父页面?
第1页.aspx
$(document).ready(function() {
$("#btnLookUp").click(function() {
$("#searchActor").dialog({
autoOpen: "false",
resizable: "false",
height: "250",
width: "320"
});
});
});
$(document).ready(function() {
$("#btnSearch").click(function() {
$("#actorsList").load("LookUp/ActorsList.aspx", { lname: $("#txtSearchCriteria").val() });
});
return false;
});
function SelectGrid(objValue, itemValue , popUpDialog) {
$(objValue).val(itemValue);
$(popUpDialog).dialog("close");
}
ActorsList.aspx 代码隐藏
private void LoadActors(string param)
{
DataTable dt = new DataTable();
//Execute stored proc
Response.Write("<table>");
foreach (DataRow dr in dt.Rows)
{
Response.Write("<tr>");
Response.Write("<td>" + "<label onclick='SelectGrid(#txtActorId,0,#searchActor'>Select</label>" + "</td>");
Response.Write("<td>" + dr[2].ToString() + "</td>");
Response.Write("<td>" + dr[3].ToString() + "</td>");
Response.Write("<td>" + dr[4].ToString() + "</td>");
Response.Write("</tr>");
}
Response.Write("</table>");
}
`
另外,请帮我解决这一行,我在如何分配值时遇到了麻烦,所以我将其设置为 0。
Response.Write("<td>" + "<label onclick='SelectGrid(#txtActorId,0,#searchActor'>Select</label>" + "</td>");