当从C#代码隐藏调用时,Jquery对话框未启动
这是我的.aspx:当从C#代码隐藏调用时,Jquery对话框未启动,c#,jquery,asp.net,C#,Jquery,Asp.net,这是我的.aspx: <div id="divAddrCandidates" class="selector" style="display:none"> <div style="margin-left:10px ; margin-top:10px"> <asp:ListBox ID="lstCandidates" runat="server" ></asp:ListBox> </div>
<div id="divAddrCandidates" class="selector" style="display:none">
<div style="margin-left:10px ; margin-top:10px">
<asp:ListBox ID="lstCandidates" runat="server" ></asp:ListBox>
</div>
<br />
<div style="margin-left:10px">
<asp:Button ID="btnSelect" runat="server" Text="Select Address" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" onclientclick="CloseAddrCandidatesWin(); return false;" />
</div>
</div>
function OpenAddrCandidatesWin() {
$("#divAddrCandidates").dialog({
resizable: true,
width: 650,
heigh: 450,
modal: true,
draggable: true,
resizable: true
});
$(".selector").dialog({ dialogClass: 'no-close' });
jQuery("#divAddrCandidates").parent().appendTo(jQuery("form:first"));
}
function CloseAddrCandidatesWin() {
$("#<%=lstCandidates.ClientID %>").val("");
$("#<%=lstCandidates.ClientID %>").hide();
$("#divAddrCandidates").dialog("close");
}
这是jQuery:
function OpenAddrCandidatesWin() {
$("#divAddrCandidates").dialog({
resizable: true,
width: 650,
heigh: 450,
modal: true,
draggable: true,
resizable: true
});
$(".selector").dialog({ dialogClass: 'no-close' });
jQuery("#divAddrCandidates").parent().appendTo(jQuery("form:first"));
}
function CloseAddrCandidatesWin() {
$("#<%=lstCandidates.ClientID %>").val("");
$("#<%=lstCandidates.ClientID %>").hide();
$("#divAddrCandidates").dialog("close");
}
函数OpenAddrCandidatesWin(){
$(“#divaddr条件”)。对话框({
可调整大小:正确,
宽度:650,
身高:450,
莫代尔:是的,
真的,
可调整大小:true
});
$(“.selector”).dialog({dialogClass:'no close'});
jQuery(“#divaddrcandates”).parent().appendTo(jQuery(“form:first”);
}
函数CloseAddrCandidatesWin(){
$(“#”)val(“”);
$(“#”)隐藏();
$(“#divaddr条件”)。对话框(“关闭”);
}
function OpenAddrCandidatesWin() {
$("#divAddrCandidates").dialog({
resizable: true,
width: 650,
heigh: 450,
modal: true,
draggable: true,
resizable: true
});
$(".selector").dialog({ dialogClass: 'no-close' });
jQuery("#divAddrCandidates").parent().appendTo(jQuery("form:first"));
}
function CloseAddrCandidatesWin() {
$("#<%=lstCandidates.ClientID %>").val("");
$("#<%=lstCandidates.ClientID %>").hide();
$("#divAddrCandidates").dialog("close");
}
这是我的代码隐藏:
function OpenAddrCandidatesWin() {
$("#divAddrCandidates").dialog({
resizable: true,
width: 650,
heigh: 450,
modal: true,
draggable: true,
resizable: true
});
$(".selector").dialog({ dialogClass: 'no-close' });
jQuery("#divAddrCandidates").parent().appendTo(jQuery("form:first"));
}
function CloseAddrCandidatesWin() {
$("#<%=lstCandidates.ClientID %>").val("");
$("#<%=lstCandidates.ClientID %>").hide();
$("#divAddrCandidates").dialog("close");
}
protected void Save_Click(object sender, System.EventArgs e)
{
JsonAddresses = WSJson.GetAddressCandidate(physicalAddrToProcess);
int count = JsonAddresses.candidates.Length;
for (int i = 0; i < count; i++)
{
lstCandidates.Items.Add(JsonAddresses.candidates[i].address.ToString());
}
string key = "_OpenAddrCandidatesWin";
string script = "OpenAddrCandidatesWin();";
if (!Page.ClientScript.IsStartupScriptRegistered(key))
{
Page.ClientScript.RegisterStartupScript(this.GetType(), key, script, true);
}
}
protectedvoid保存\u单击(对象发送方,System.EventArgs e)
{
JsonAddresses=WSJson.GetAddressCandidate(PhysicalAddressToProcess);
int count=jsonaddress.candidates.Length;
for(int i=0;i
我错过了什么?代码没有出错,但是对话框没有弹出,虽然我在jquery上设置了一个中断,但它从未停止。任何帮助都将不胜感激。这可能是因为您在加载dom之前就执行了该方法
function OpenAddrCandidatesWin() {
$("#divAddrCandidates").dialog({
resizable: true,
width: 650,
heigh: 450,
modal: true,
draggable: true,
resizable: true
});
$(".selector").dialog({ dialogClass: 'no-close' });
jQuery("#divAddrCandidates").parent().appendTo(jQuery("form:first"));
}
function CloseAddrCandidatesWin() {
$("#<%=lstCandidates.ClientID %>").val("");
$("#<%=lstCandidates.ClientID %>").hide();
$("#divAddrCandidates").dialog("close");
}
尝试更改
string script=“OpenAddrCandidatesWin();”
tostring script=“$(函数(){OpenAddrCandidatesWin();})”代码>将等待dom加载,然后执行该方法。谢谢S。但它不起作用。我将代码作为一个单独的项目运行,它运行良好,但当我将其连接到一个存在的应用程序时,我遇到了这个问题。我在控制台中没有任何错误,我尝试使用IE的调试器F12,但遇到“脚本调试器无法连接到目标进程”。我已经尝试了很多方法,但无法摆脱这个消息。我在jquery中设置了break,但它似乎从未停止过。你能在Chrome中尝试吗?我正在开发的应用程序只为IE设置,不能在其他浏览器上运行。你可以看到我有多沮丧:)我可以理解,但我只是想检查页面加载是否有任何错误。根据我的经验,Chrome是调试JavaScript问题的最佳浏览器。
function OpenAddrCandidatesWin() {
$("#divAddrCandidates").dialog({
resizable: true,
width: 650,
heigh: 450,
modal: true,
draggable: true,
resizable: true
});
$(".selector").dialog({ dialogClass: 'no-close' });
jQuery("#divAddrCandidates").parent().appendTo(jQuery("form:first"));
}
function CloseAddrCandidatesWin() {
$("#<%=lstCandidates.ClientID %>").val("");
$("#<%=lstCandidates.ClientID %>").hide();
$("#divAddrCandidates").dialog("close");
}