Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 从代码隐藏创建动态ModalPopupXtender不起作用_Asp.net_Dynamic_Code Behind_Modalpopupextender - Fatal编程技术网

Asp.net 从代码隐藏创建动态ModalPopupXtender不起作用

Asp.net 从代码隐藏创建动态ModalPopupXtender不起作用,asp.net,dynamic,code-behind,modalpopupextender,Asp.net,Dynamic,Code Behind,Modalpopupextender,我试图从后面的代码中创建一个动态ModalPopupXtender,当我单击按钮时,它会弹出一个侧面有一个按钮的面板。 我创建了一个面板(名为panel),侧面有一个名为ButtonOk(button.id=“ButtonOk”)的按钮 但是,当我单击第一个按钮(button\u click)的事件处理程序时,什么都没有发生,请帮助我,我的代码是: protected void Button_Click(object sender, EventArgs e) { HiddenField

我试图从后面的代码中创建一个动态ModalPopupXtender,当我单击按钮时,它会弹出一个侧面有一个按钮的面板。 我创建了一个面板(名为panel),侧面有一个名为ButtonOk(button.id=“ButtonOk”)的按钮 但是,当我单击第一个按钮(button\u click)的事件处理程序时,什么都没有发生,请帮助我,我的代码是:

protected void Button_Click(object sender, EventArgs e)
{
    HiddenField hf = new HiddenField();
    hf.ID = "hdnField";


    AjaxControlToolkit.ModalPopupExtender modalPop = new    AjaxControlToolkit.ModalPopupExtender();
    modalPop.ID = "ModalPopupExtenderSelectFilds";
    modalPop.PopupControlID =Convert.ToString(Page.FindControl(Convert.ToString(panel.ClientID))); //panel.ID;
    modalPop.TargetControlID = Convert.ToString(Page.FindControl(Convert.ToString(hf.ClientID))); //"hdnField";        
    modalPop.OkControlID = "ButtonOk";
    modalPop.BackgroundCssClass = "modalBackground";
    modalPop.BehaviorID = "modalPopupExtenderSelectFilds";

    modalPop.Show();
}

为了获得其他用户的帮助,您只需将modalPop添加到控件将添加到页面的区域中

例如,这应该添加到代码的末尾

panel1.Controls.Add(modalPop);

选中此代码可将控件添加到面板:-


this.panel1.Controls.Add(modalPop)

在代码隐藏中,您可以:

if (true)
{
var script = @"Sys.Application.add_load(function() { $find('behavoirIDModal').show(); });";
ScriptManager.RegisterStartupScript(this, GetType(), "ShowPopup", script, true);
}

编辑:behavoirIDModal

我想你必须在面板中添加控件。controls.add()试试这个Prabhavith是对的,除非您将控件添加到页面,否则它将不会在我的面板中呈现我有复选框控件和按钮按钮确定我现在如何将面板添加到页面控件以及是否需要将ModalPopupXtender添加到页面控件?