【发布时间】:2015-11-16 12:54:55
【问题描述】:
我正在尝试将数据从模态表单获取到父表单,但我无法做到。我正在使用 webusercontrol 创建 jquery 模态表单并在 gridview 中显示数据。我想获取选定的行并将其添加到我父表单的网格中。 我正在使用此代码创建我的对话框表单
function dialogAc(ID1) {
$.ajax({
type: 'POST',
url: '<%= ResolveUrl("/faturaIrsaliye/FaturaKaydet.aspx/abc") %>',
data: "{ID1:'" + ID1 + "' }",
dataType: 'json',
async: true,
cache: false,
contentType: 'application/json; charset=utf-8',
success: function (msg) {
$("#IrsaliyeDetay").append(msg.d);
},
failure: function (msg) {
alert("Error");
}
});
ID11 = ID1;
$("#dialog-form").dialog("open");
}
这是我的创作方法。
[WebMethod]
public static string abc(String ID1)
{
string sonuc = "";
Page p = new Page();
UserControl u = (UserControl)p.LoadControl("~/faturaIrsaliye/WebUserControl1.ascx");
WebUserControl1 kk = (u as WebUserControl1);
kk.irsaliyeBaslikID = ID1.toInt();
p.Controls.Add(u);
StringWriter sw = new StringWriter();
HttpContext.Current.Server.Execute(p, sw, false);
sonuc = sw.ToString();
sw.Close();
return sonuc;
}
到目前为止一切都很好。 最后一个代码不会触发我的其他方法。我收到 404 not found 错误。
$(function () {
$("#dialog-form").dialog({
autoOpen: false,
height: 500,
width: 800,
modal: true,
buttons: [{
text: "Select",
click: function () {
$.ajax({
type: 'POST',
url: '<%= ResolveUrl("/faturaIrsaliye/WebUserControl1.ascx/abc") %>',
data: "{}",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (result) {
$('#sonuc').html(result.d);
alert("clicked");
},
error: function (response) {
alert(response.status + ' ' + response.statusText);
}
});
},
}, {
text: "Close",
click: function () {
$(this).dialog('close');
//window.location.reload(true);
return false;
}
}
]
});
});
【问题讨论】:
标签: c# jquery asp.net asp.net-ajax