我已经将一个按钮添加到一个更新面板中,它位于一个 juiceUI 对话框 div 中。通过单击超链接显示对话框(参见代码)。这行得通。通过 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";
}