Javascript 从JqueryDialog调用vbsub

Javascript 从JqueryDialog调用vbsub,javascript,jquery,asp.net,vb.net,Javascript,Jquery,Asp.net,Vb.net,所以我有一个表单,这个表单的一部分将用于创建jquery对话框。从该对话框中,我将单击一个由asp服务器控件创建的按钮。服务器控件在代码隐藏中有一个函数,单击该函数时将调用该函数。我遇到的问题是代码背后的函数没有被调用。我有没有遗漏一些基本的东西?以下是aspx页面的外观,精简到最低限度 <head> <script> function PreviewForm() { $("#emailPrev

所以我有一个表单,这个表单的一部分将用于创建jquery对话框。从该对话框中,我将单击一个由asp服务器控件创建的按钮。服务器控件在代码隐藏中有一个函数,单击该函数时将调用该函数。我遇到的问题是代码背后的函数没有被调用。我有没有遗漏一些基本的东西?以下是aspx页面的外观,精简到最低限度

<head>
<script>        
     function PreviewForm() {              
            $("#emailPreview").attr("style", "");
            $("#emailPreview").dialog({
                title: "Preview",
                width: "890px",
                modal: true
            });
        }               
</script>
</head>
<body>
<form id="EmailSend" method="post" runat="server">  
    <table>
        <tr>
            <td style="text-align:right">                                                   
                <input type="button" onclick="PreviewForm();" value="Preview" />                                                   
            </td>
        </tr>
    </table>    
    <div id="emailPreview" align="center" style="display:none">
        <fieldset>
           <table>
                <tr class="Row">
                    <td class="required">Subject:</td>
                    <td><asp:Label ID="lblSubj" Runat="server" /></td>
                </tr>
                <tr>
                    <td class="field" colspan="2" style="text-align:center">                       
                       <input id="btnBack" class="button" type="button" onclick="closeDialog(false);" value="Close" />&nbsp;                           
                       <asp:Button ID="Send" class="button" Runat="server" Text="Send"/>
                    </td>
                </tr>
            </table>
        </fieldset>
    </div>              
</form>        
当我尝试调试代码时,没有发生任何事情,断点没有被击中。如果我要使按钮可见,并从我创建的对话框外部单击,那么它将正常工作

编辑

我还尝试了在对话框外隐藏按钮,然后在对话框关闭后单击按钮。因此,closeDialog函数与新的输入按钮类似

function closeDialog(send) {
    console.log(send);
       if (send) {
           $("#emailPreview").dialog("close");
           GetFormControl('<%=Send.ClientID%>').click();  
           console.log(send + " TRUE");
        } else {
            $("#emailPreview").dialog("close");
            console.log(send + " false");
        }                
 }


<div id="emailPreview" align="center" style="display:none">
        <fieldset>
           <table>
                <tr class="Row">
                    <td class="required">Subject:</td>
                    <td><asp:Label ID="lblSubj" Runat="server" /></td>
                </tr>
                <tr>
                    <td class="field" colspan="2" style="text-align:center">                                 
             <input id="btnBack" class="button" type="button" onclick="closeDialog(false);" value="Close" />&nbsp;
             <input type="button" onclick="closeDialog(true);" value="Send Email" />

                    </td>
                </tr>
            </table>
        </fieldset>
    </div> 
        <asp:Button ID="Send" class="button" Runat="server" Text="Send"/>             
</form>        
编辑2

根据要求,我也知道如何使用eval,但我在这里维护了其他人的代码。所以让我们假装它是好的

 function GetFormControl(fControlName) {
            var oControl = eval('document.EmailSend.' + fControlName);
            if (oControl == null)
                oControl = GetPageElement(fControlName);
            return oControl;
        }

问题是jQueryUIDialog函数将对话框的HTML附加到表单元素之外。有关解决方案,请参见以下问题:

答案:改变

$("#emailPreview").dialog({
    title: "Preview",
    width: "890px",
    modal: true
});


什么是GetFormControl()?你可能需要展示一下that@attila我已经更新了我的编辑以包含函数well,因为错误显示GetFormControl的结果为null/未定义,您是否可以尝试用
document.getElementById(“”)替换它。单击()?@attila我仍然收到相同的错误。我还使用jquery
$(“#”)
进行了reied,我认为下一步是查看呈现的html/javascript源代码。我看不出代码有任何明显的错误,但您可能希望仔细检查asp.net实际输出的内容。此外,我建议使用firebug或类似的工具来查看任何其他错误。
 function GetFormControl(fControlName) {
            var oControl = eval('document.EmailSend.' + fControlName);
            if (oControl == null)
                oControl = GetPageElement(fControlName);
            return oControl;
        }
$("#emailPreview").dialog({
    title: "Preview",
    width: "890px",
    modal: true
});
var diag = $("#emailPreview").dialog({
    title: "Preview",
    width: "890px",
    modal: true
});
diag.parent().appendTo(jQuery("form:first"));