Javascript 如何在第二次打开jquery对话框时仅刷新其内容

Javascript 如何在第二次打开jquery对话框时仅刷新其内容,javascript,jquery,asp.net,html,jquery-dialog,Javascript,Jquery,Asp.net,Html,Jquery Dialog,我正在单击函数中打开一个jquery对话框。但是如果我关闭对话框并再次打开它,对话框中的内容将保持不变。。当我连续打开对话框时,我需要对话框中的文本框为空 这是我的aspx代码: <div> <span id="id_PrivateSpace" style="color: #88b807; margin-left: 839px; margin-top: -12px; cursor: pointer; display: bl

我正在单击函数中打开一个jquery对话框。但是如果我关闭对话框并再次打开它,对话框中的内容将保持不变。。当我连续打开对话框时,我需要对话框中的文本框为空

这是我的aspx代码:

<div>
<span id="id_PrivateSpace" style="color: #88b807; margin-left: 839px;
                            margin-top: -12px; cursor: pointer; display: block">Create</span>
</div>


<div id="thedialog" style="display: none; overflow: hidden">
                    <table id="table" style="border-spacing: 7px 7px; margin-left: 5px">
                        <tr>
                            <td>
                                <span class="SubHeading" style="font-size: 10pt;">Private Space Name </span>
                            </td>
                            <td>
                                <asp:TextBox ID="txt_spacename" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span class="SubHeading" style="font-size: 10pt;">Private Space Description </span>
                            </td>
                            <td>
                                <asp:TextBox ID="txt_spacedesc" TextMode="MultiLine" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span class="SubHeading" style="font-size: 10pt;">Users </span>
                            </td>
                            <td>

                                <input type="text" id="txt_users" />
                            </td>
                            <td>
                                <asp:Button ID="btn_addusers" Text="Add" Style="margin-left: 10px;" runat="server" />
                            </td>
                            <td rowspan="5">
                                <table id="users_grid" align="left">
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span class="SubHeading" style="font-size: 10pt;">DL </span>
                            </td>
                            <td>
                                <asp:TextBox ID="txt_Add_dl" TextMode="MultiLine" runat="server" />
                            </td>
                        </tr>
                    </table>
                    <input type="button" id="Btn_Submit" value="Create" style="margin-left: 335px; margin-top: 35px;"
                        runat="server" />
                </div>
我应该添加什么来只刷新对话框的内容?

我想您可以试试:

$('#id_PrivateSpace').click(function() {
    $("#thedialog").find('input:text, textarea').val('').attr('placeholder','Enter some value');
    $("#thedialog").find('select').val('');//you need to have and option like <option value="">Please Select</option> in your select options list
    $('#thedialog').dialog('open');
    return false;
}); 
$('#id_PrivateSpace')。单击(函数(){
$(“#对话框”).find('input:text,textarea').val(''.attr('placeholder','Enter some value');
$(“#thedialog”).find('select').val(“”);//您需要在选择选项列表中具有和请选择类似的选项
$('thedialog')。对话框('open');
返回false;
}); 
对于您的aspx Dropdownlist,请确保将AppendDataBoundItems设置为true;并设置OnDataBinding事件

<asp:DropDownList id="myDdl" runat="server" OnDataBinding="Ddl_Databinding" >
</asp:DropDownList>

And in your code behind, Add:

protected void Ddl_Databinding(object sender, EventArgs e)
{
    DropDownList ddl = (DropDownList)sender;
    ddl.Items.Add(new ListItem("Please Select", ""));
}

在代码隐藏中,添加:
受保护的无效Ddl_数据绑定(对象发送方、事件参数)
{
DropDownList ddl=(DropDownList)发送方;
ddl.Items.Add(新列表项(“请选择“,”));
}
试试看


在关闭时添加以下函数以销毁jquery对话框的特定实例:

close: function()
    {
        $(this).dialog('close');
        $(this).dialog('destroy');
        $(this).html("");
    },

这是我在动态创建对话框时遇到类似问题时不得不使用的代码。

谢谢你的帮助。。但多行文本框的内容保持不变。。如何做到这一点呢?请帮助是否可以获取asp dropdownlist的输入类型(如文本和TextArea)以输入或TextArea的形式实际呈现为html。如果您还想清除dropdownlist的值,可以使用多行文本框值。。如何更新?
$('#id_PrivateSpace').click(function() {
  $("#thedialog input[type='text']").val('');
  $("#thedialog textarea").html('');
  $('#thedialog').dialog('open');
  return false;
}); 
<form id="myform>
<div id =thedialog> ....... </div>
</form>
    document.getElementById("form1").reset();
close: function()
    {
        $(this).dialog('close');
        $(this).dialog('destroy');
        $(this).html("");
    },