Update Panels, Master Pages and Modal Dialog Boxes

Last post 12-06-2006 8:02 AM by hardpolo. 1 replies.

Sort Posts:

  • Update Panels, Master Pages and Modal Dialog Boxes

    11-01-2006, 9:27 AM
    • Loading...
    • DrClick
    • Joined on 11-28-2005, 9:36 PM
    • Posts 16

    I seem to have a problem with modal dialog boxes, when I open them from inside my content page, it fills the content container (and not the top and left nav supplied by the masterpage). My guess is this has to do with the div the content placeholder is in is set to position relative to deal with the ie fixed relative postioning issue. So my solution is to but a panel in my masterpage along with a modal popup extender.

    What I am trying to do. When I click add on one of many custom gridview controls contained in updatepanels on a page, it opens the appropriate add formview control in the center of the screen as a modal form.

    So summary, master page has an update panel which contains a panel for a formview and a panel for datasources. Master page also has a proxy button and modal dialog display extender

    content page has formviews, datasources and multiple add buttons inside updatepanels.

    When I click add, I call a method on the masterpage which adds the formview and datasources to the appropriate panels and then calls update on the updatePanel. Finally the add click event registers a javascript which "clicks" the masterpages proxy button to activate the modal dialog box extender.

     This works great the first time you click add, form shows up. Next time you do it, I get datasource errors.

    Finally, I have to figure out a way to update the update panel that originated the add function.

    Code Snippets:

    Masterpage -

    <asp:Panel ID="GenericAddPanel" runat="server">
     
    <atlas:UpdatePanel ID="upnlAdd" runat="server" Mode="Conditional">
      <ContentTemplate>
       <asp:panel ID="pnlFormview" runat="server"/>
       <asp:Panel ID="pnlDatasources" runat="server" />
      </ContentTemplate>
     </atlas:UpdatePanel>
     <asp:Button ID="btnAddOk" runat="server" CommandName="Insert" CssClass="button" Text="Add" />
     <asp:Button ID="btnAddCancel" runat="server" CommandName="Cancel" CssClass="button" Text="Cancel" />
    </asp:Panel>

    <asp:Button ID="btnAddProxy" runat="server" Height="1px" CssClass="hidden" />

    <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server">
     <cc1:ModalPopupProperties TargetControlID="btnAddProxy" OkControlID="btnAddOk" PopupControlID="GenericAddPanel" CancelControlID="btnAddCancel" BackgroundCssClass="modalBackground"></cc1:ModalPopupProperties>
    </cc1:ModalPopupExtender>

    --Add Clicked event in the content page

    void gvcAddress_AddClicked(object sender, EventArgs e)

    {

    //add the form the masterpages update panel

    fviewAddress.Visible = true;

    //create an array of the needed datasources

    ObjectDataSource[] myDS = new ObjectDataSource[3];

    myDS[0] = odsAddress;

    myDS[1] = odsCountres;

    myDS[2] = odsStates;

    Master.AddFormViewToAddPanel(fviewAddress, myDS);

     

    //register a client side script to click the masterpages addItem proxy button

    String script = @"$('ctl00_btnAddProxy').click();";

    Page.ClientScript.RegisterClientScriptBlock(typeof(string), "ClickAddAddressButton", script, true);

     

     

     

    --Finally the add event in the masterpage

    public void AddFormViewToAddPanel(FormView pFormView, ObjectDataSource[] pDatasources)

    {

    //add each of the datasources to the datasources panel

    foreach (ObjectDataSource ods in pDatasources)

    {

    pnlDatasources.Controls.Add(ods);

    }

    //now add the from view

    pnlFormview.Controls.Add(pFormView);

    //force update of the panel

    this.upnlAdd.Update();

    }

     

     

     

  • Re: Update Panels, Master Pages and Modal Dialog Boxes

    12-06-2006, 8:02 AM
    • Loading...
    • hardpolo
    • Joined on 11-17-2006, 9:51 AM
    • Posts 8
    I'm having this same issue...    Is there anyone out there smart enough to figure this out...  any MVP???
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter