在带有更新面板的Juice UI对话框中回发后控制失去样式

时间:2014-07-30 12:10:10

标签: jquery asp.net updatepanel postback juice-ui

我在juiceUI对话框div中的updatepanel中添加了一个Button。 单击超链接即可显示该对话框(请参阅代码)。这有效。 通过Button-Click事件成功回发后,所有控件都会丢失其样式(使用Fresh-Squeezed)。我找不到原因。 注意:我想在代码隐藏中生成所有控件。

 protected void Page_Load(object sender, EventArgs e)
{
    ScriptManager man = new ScriptManager();
    man.SupportsPartialRendering = true;

    this.Form.Controls.Add(man);

    HyperLink lnkOpen = new HyperLink(); lnkOpen.ID = "lnkOpen"; lnkOpen.Text = "open Dialog"; lnkOpen.CssClass = "open-dialog";
    this.Form.Controls.Add(lnkOpen);

    Juice.Dialog jDialog = new Dialog(); jDialog.ID = "jdialog";
    jDialog.Modal = true;
    jDialog.TargetControlID = "dialogItSelf";
    jDialog.AutoOpen = false;
    this.Form.Controls.Add(jDialog);

    UpdatePanel updPanel1 = new UpdatePanel(); updPanel1.ID = "upd1";        
    System.Web.UI.WebControls.Button buttonOK = new System.Web.UI.WebControls.Button(); buttonOK.ID = "button";
    buttonOK.Click += new EventHandler(buttonOK_Click);        
    updPanel1.ContentTemplateContainer.Controls.Add(buttonOK);

    Panel basicDialog = new Panel(); basicDialog.ID = "dialogItSelf"; basicDialog.CssClass = "basic-dialog";

    basicDialog.Controls.Add(updPanel1);

    this.Form.Controls.Add(basicDialog);

    this.Form.Controls.Add(
        new LiteralControl("<script>$( \".open-dialog\" ).click( function ( e ) {" +
    "e.preventDefault();" +
    "$( \".basic-dialog\" ).dialog( \"open\" );" +
        "});</script>")
        );
}

void buttonOK_Click(object sender, EventArgs e)
{
    (sender as System.Web.UI.WebControls.Button).Text = "clicked";
}

0 个答案:

没有答案