如何在回发后保持模态弹出窗口打开

时间:2013-12-27 18:48:24

标签: asp.net popup postback modalpopupextender webusercontrol

//this is my interface

 public interface IPopupGrid 
 {
     void PopupClosed(string key);
     void PopupGridPageChanging(string key);
     void PopupFilterButtonClicked(string key);
     void PopupOkButtonClicked(string key);
     void PopupGridSorting(string key);
 }

//this is the class that implements the interface
//on buton click this loads a grid in modal popup extender
public partial class CustomerChargesMaster : IPopupGrid
{
    public void PopupClosed(string key)
    {
        if (key == "Customer")
            CloseCustomerPopup();
    }

    public void PopupGridPageChanging(string key)
    {
        if (key == "Customer")
            ShowCustomerPopup();
    }

    public void PopupFilterButtonClicked(string key)
    {
        if (key == "Customer")
            ShowCustomerPopup();
    }

    public void PopupOkButtonClicked(string key)
    {
        if (key == "Customer")
            CustomerSelected();
    }

    public void PopupGridSorting(string key)
    {
        if (key == "Customer")
            ShowCustomerPopup();
    }

    private void CloseCustomerPopup()
    {
        CustomerPopupExtender.Hide();
    }

    private void ShowCustomerPopup()
    {
        CustomerPopupExtender.Show();
    }

    protected void SelectCustomerButton_Click(object sender, EventArgs e)
    {
        CustomerPopup.CssClass = "";
        CustomerPopupGrid.GridMode = PopupGridMode.SingleSelect;
        CustomerPopupGrid.LoadPopupControl("Customer", this);

        CustomerPopupExtender.Show();
    }

    private void CustomerSelected()
    {
    }
}

//code inside user control
public partial class GenericPopupGrid : System.Web.UI.UserControl
{
    public void LoadPopupControl(string key, IPopupGrid caller)
    {
        if (string.IsNullOrEmpty(key))
            return;

        _key = key;
        ViewState["PopupGridKey"] = key;

        _caller = caller;
        //Session["Caller"] = caller;

        listModel = ModelFactory.GetPopupGridModel(_key);

        if (listModel == null)
        {
            return;
        }

        PopupHeaderLabel.Text = listModel.GridTitle;

        BindGenericPopupGridView();
        GenericPopupGridView.BottomPagerRow.Visible = true;
    }

    protected void FilterOkButton_Click(object sender, EventArgs e)
    {
         //calling the caller class method to keep the popup open
        _caller.PopupOkButtonClicked(_key);
    }
}

我有一个带网格的Web用户控件,我根据传递的密钥加载不同的数据 这被称为弹出窗口,使用来自aspx页面的模态弹出扩展器

现在进行任何回发都会关闭网格 所以我使用界面调用调用者页面中的方法,这将保持弹出窗口打开 但这不符合预期

如果我在UserControl中添加一个EventHandler并在aspx页面中附加一个方法,那么弹出窗口仍然打开

还有其他更简单的方法吗?我不想编写代码来将方法附加到甚至处理程序和方法本身的所有调用弹出窗口的aspx页面。

代码如上

0 个答案:

没有答案