标签未在asyncpostbacktrigger触发的jQuery对话框中更新

时间:2017-05-16 14:04:04

标签: jquery asp.net updatepanel

我拥有的是什么。

在我的.aspx文件中:

这是更新面板,其中包含用于打开对话框的按钮。

<asp:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true" RenderMode="Inline">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
    </Triggers>
    <ContentTemplate>
        <%--(A GridView)--%>
        <asp:Button ID="Button2" runat="server" OnClick="BtnReport_Click" />
    </ContentTemplate>
</asp:UpdatePanel>

在更新之外有对话框的div。

<div class="dialog-report" style="font-size: medium;">
    <div>
        <asp:Label ID="LblReport" runat="server" Text=""></asp:Label>
    </div>
    <div>
        <asp:TextBox ID="TxtBox_Report" runat="server" TextMode="MultiLine"></asp:TextBox>
    </div>
</div>

对于我所做的对话框的配置:

$(".dialog-report").dialog({
    resizable: false,
    modal: true,
    title: "Sala de Comando",
    height: 400,
    width: 300,
    autoOpen: false,
    appendTo: "form"
});

在C#代码隐藏中

protected void BtnReport_Click(object sender, EventArgs e)
{
    ScriptManager.RegisterStartupScript(this.UpdatePanel,GetType(), "open-dialog", "$('.dialog-report').dialog('open');", true);
    LblReport.Text = "some text";
}

Actualy对话框打开但对标签没有任何作用,它在标签的位置没有显示任何内容。什么时候会有文字&#34;一些文字&#34;。 任何帮助,提前tks。

如果我使用asp:postback标签获取文本如果我使用asp:asyncpostback它不会

2 个答案:

答案 0 :(得分:0)

您的代码段中的所有错误中的一部分,它甚至不允许编译或者会给您一个ysod ...您在哪里找到.dialog('open')?只需在某处键入open就不会发生这种情况。

删除它,模态将打开。

ScriptManager.RegisterStartupScript(this.UpdatePanel, GetType(), "open-dialog", "$('.dialog-report').dialog();", true);

答案 1 :(得分:0)

我在对话框中使用了一个新的更新面板(UpdatePanel1)。

在代码隐藏中添加了UpdatePanel1.Update();