使链接在弹出窗口中显示div

时间:2012-09-21 13:53:35

标签: javascript asp.net html

我正在尝试获取一个链接以在弹出窗口中显示div。

这是我的链接:

<li><a class="newAttachmentType" onclick="getFiles(true)">Move to somewhere</a></li>

这是我试图调用并放入弹出窗口的div:

<div id="ddlFiles">
    <label>
        Select new CaseFile:</label>
    <asp:DropDownList runat="server" ID="ddlCaseFilesNew" DataSourceID="dsCaseFiles"
        DataTextField="Display" DataValueField="FileID" OnPreRender="ddl_PreRender" Width="300px" />
    <label>
        Select old CaseFile:</label>
    <asp:DropDownList runat="server" ID="ddlCaseFilesOld" DataSourceID="dsCaseFiles"
        DataTextField="Display" DataValueField="FileID" OnPreRender="ddl_PreRender" Width="300px" />
</div>

这是我迄今为止在“getFiles()”中尝试过的:

$('.newAttachmentType').click(function () {
   $('#newAttachmentDialog').dialog({
       autoOpen: true,
       height: 'auto',
       width: 'auto',
       modal: true,
       buttons: {
         "Save": function () {
            var attachmentName = $('#txtNewAttachmentName').val();
            if (attachmentName != "") {
                 var res;
                 PageMethods.addNewAttachmentType(attachmentName, reloadAttachmentTypes, res);
                 $(this).dialog('close');
            }
      },
      Cancel: function () {
            $(this).dialog('close');
      }
   },
   beforeClose: function () { $('#txtNewAttachmentName').val(''); }
 });
});

1 个答案:

答案 0 :(得分:1)

您正在onclick方法中分配点击处理程序。为时已晚,无法发挥作用。

不要像这样分配点击处理程序,而是直接执行代码。基本上打开内部函数:

$('#newAttachmentDialog').dialog({ 
   //Your code
});