Solved

How do I prevent AutoPostBack from closing the ModalPopupExtender Panel?

Posted on 2007-11-20
2
3,979 Views
Last Modified: 2012-05-05
I placed a Formview inside a Panel inside an UpdatePanel. A Button triggers the ModalPopupExtender which displays the formview. I can change and update any field on the form. CalendarExtenders work just fine, too. But when I try to do something fancy like programmatically change the DueDate and OverDueDate fields, the formview closes and returns to the calling page.

How can I call my class methods without closing the modal popup panel?

Thanks for any thoughts or ideas.
The Lakeman
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="EditMyMeter.aspx.vb" Inherits="EditMeter" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Meter Information Page</title>
    <link rel="stylesheet" type="text/css" />
    <link href="MetersStyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Scripts>
        </Scripts>
        </asp:ScriptManager>
    </div>
    <div>
        <asp:TextBox ID="SelectedIDTextBox" runat="server" Visible="False">000013</asp:TextBox>
          <br />
    </div> 
    <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
         <asp:Button ID="TestHyperLink" runat="server" Text="Change Testing Dates" />
        <br />
        <asp:Panel ID="Panel2" runat="server" Height="50px" Width="125px" BorderStyle="Double" CssClass="modalpopup">
        <asp:FormView ID="TestFormView" runat="server" DataSourceID="MeterTestObjectDataSource"
        DefaultMode="Edit" CellPadding="4" ForeColor="#333333" >
          
            <EditItemTemplate>
                <table >
                    <tr>
                        <th colspan="2">
                            Change the dates or frequency to set the next Test Date for meter &nbsp;<asp:Label ID="IDTextBox" runat="server" Text='<%# Bind("ID") %>'>
                </asp:Label></th>
                     </tr>
                    <tr>
                        <th>
                            Frequency:
                        </th>
                        <th>
                        <asp:RadioButtonList ID="FrequencyRadioButtonList" runat="server" AutoPostBack="true" SelectedValue='<%# Bind("TestFrequency") %>'
                                Width="128px" OnSelectedIndexChanged="FrequencyRadioButtonList_SelectedIndexChanged" >
                                <asp:ListItem Value="1">Monthly</asp:ListItem>
                                <asp:ListItem Value="3">Quarterly</asp:ListItem>
                                <asp:ListItem Value="6">Semi-Annual</asp:ListItem>
                                <asp:ListItem Value="12">Annual</asp:ListItem>
                            </asp:RadioButtonList></th>
                            </tr>
                            <tr>
                                <th style="vertical-align: top">
                                    Last Date Tested:
                                    <br />
                                </th>
                                <th>
                                <asp:TextBox ID="LastTestDateTextBox" runat="server" Text='<%# Bind("LastTestDate") %>'>
                                </asp:TextBox>                
                        </th>
                            </tr>
                            <tr>
                                <th>
                                    Due Date:</th>
                                <th>
                        <asp:TextBox ID="TestDueDateTextBox" runat="server" Text='<%# Bind("TestDueDate") %>'>
                        </asp:TextBox></th>
                            </tr>
                            <tr>
                                <th>
                                    Test Day:&nbsp;</th>
                                <th>
                        <asp:TextBox ID="TestDayTextBox" runat="server" Text='<%# Bind("TestDay") %>'>
                        </asp:TextBox></th>
                            </tr>
                            <tr>
                                <th>
                                    Over DueDate:
                                    <br />
                                </th>
                                <th>
                        <asp:TextBox ID="TestOverDueDateTextBox" runat="server" Text='<%# Bind("TestOverDueDate") %>'>
                        </asp:TextBox></th>
                            </tr>
                        
                        </table>
                        <asp:Button ID="UpdateButton" runat="server" Text="Update" CausesValidation="true" CommandName="Update"/>
                        <asp:Button ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                            Text="Cancel">
                        </asp:Button>
                        <cc1:MaskedEditExtender ID="MaskedEditExtender1" runat="server"
                            TargetControlID="LastTestDateTextBox" 
                            Mask="99/99/9999"
                            MessageValidatorTip="true"
                            OnFocusCssClass="MaskedEditFocus"
                            OnInvalidCssClass="MaskedEditError"
                            MaskType="Date"
                            AcceptAMPM="false"
                            ErrorTooltipEnabled="True" />
                        <cc1:MaskedEditValidator ID="MaskedEditValidator1" runat="server"
                            ControlExtender="MaskedEditExtender1"
                            ControlToValidate="LastTestDateTextBox"
                            IsValidEmpty="False"
                            EmptyValueMessage="Date is required"
                            InvalidValueMessage="Date is invalid"
                            Display="Dynamic"
                            TooltipMessage="Input the change date"
                            EmptyValueBlurredText="*"
                            InvalidValueBlurredMessage="This is not a valid date"
                            ValidationGroup="MKE" />
                        <br />
                            <cc1:CalendarExtender ID="CalendarExtender2" runat="server" PopupButtonID="InstalledImageButton"
                                PopupPosition="TopLeft" TargetControlID="LastTestDateTextBox">
                            </cc1:CalendarExtender>
                            <asp:RequiredFieldValidator ID="LastTestedRequiredFieldValidator" runat="server" 
                            ErrorMessage="RequiredFieldValidator"
                            ControlToValidate="LastTestDateTextBox"
                            ></asp:RequiredFieldValidator>
                            <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="RangeValidator"
                            ControlToValidate="LastTestDateTextBox"
                            Type="Date"
                            MinimumValue="01/01/1950"
                            MaximumValue="12/31/2020"
                            Text="The date must be valid and between 1950 and 2020"
                            ></asp:RangeValidator>
            </EditItemTemplate>
            <InsertItemTemplate>
                ID:
                <asp:TextBox ID="IDTextBox" runat="server" Text='<%# Bind("ID") %>'>
                </asp:TextBox><br />
                LastTestDate:
                <asp:TextBox ID="LastTestDateTextBox" runat="server" Text='<%# Bind("LastTestDate") %>'>
                </asp:TextBox><br />
                TestFrequency:
                <asp:TextBox ID="TestFrequencyTextBox" runat="server" Text='<%# Bind("TestFrequency") %>'>
                </asp:TextBox><br />
                TestDay:
                <asp:TextBox ID="TestDayTextBox" runat="server" Text='<%# Bind("TestDay") %>'>
                </asp:TextBox><br />
                TestDueDate:
                <asp:TextBox ID="TestDueDateTextBox" runat="server" Text='<%# Bind("TestDueDate") %>'>
                </asp:TextBox><br />
                TestOverDueDate:
                <asp:TextBox ID="TestOverDueDateTextBox" runat="server" Text='<%# Bind("TestOverDueDate") %>'>
                </asp:TextBox><br />
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                    Text="Insert">
                </asp:LinkButton>
                <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="Cancel">
                </asp:LinkButton>
            </InsertItemTemplate>
            <ItemTemplate>
                ID:
                <asp:Label ID="IDLabel" runat="server" Text='<%# Bind("ID") %>'></asp:Label><br />
                LastTestDate:
                <asp:Label ID="LastTestDateLabel" runat="server" Text='<%# Bind("LastTestDate") %>'>
                </asp:Label><br />
                TestFrequency:
                <asp:Label ID="TestFrequencyLabel" runat="server" Text='<%# Bind("TestFrequency") %>'>
                </asp:Label><br />
                TestDay:
                <asp:Label ID="TestDayLabel" runat="server" Text='<%# Bind("TestDay") %>'></asp:Label><br />
                TestDueDate:
                <asp:Label ID="TestDueDateLabel" runat="server" Text='<%# Bind("TestDueDate") %>'>
                </asp:Label><br />
                TestOverDueDate:
                <asp:Label ID="TestOverDueDateLabel" runat="server" Text='<%# Bind("TestOverDueDate") %>'>
                </asp:Label><br />
                <asp:LinkButton ID="TestEditButton" runat="server" CausesValidation="False" CommandName="Edit"
                    Text="Edit">
                </asp:LinkButton>
                <asp:LinkButton ID="TestNewButton" runat="server" CausesValidation="False" CommandName="New"
                    Text="New">
                </asp:LinkButton>
            </ItemTemplate>
            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <HeaderTemplate>
                <span class="modallabels">Change Testing Dates</span>
            </HeaderTemplate>
        </asp:FormView>
        <asp:ObjectDataSource ID="MeterTestObjectDataSource" runat="server" InsertMethod="Insert"
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetTestDateByID"
            TypeName="MetersDataSetTableAdapters.TESTSCHEDULESTableAdapter" UpdateMethod="UpdateTestDateQuery">
            <UpdateParameters>
                <asp:Parameter Name="LastTestDate" Type="DateTime" />
                <asp:Parameter Name="TestFrequency" Type="String" />
                <asp:Parameter Name="TestDay" Type="String" />
                <asp:Parameter Name="TestDueDate" Type="DateTime" />
                <asp:Parameter Name="TestOverDueDate" Type="DateTime" />
                <asp:Parameter Name="ID" Type="String" />
            </UpdateParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="SelectedIDTextBox" Name="ID" PropertyName="Text"
                    Type="String" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="ID" Type="String" />
                <asp:Parameter Name="TestFrequency" Type="String" />
                <asp:Parameter Name="TestDay" Type="String" />
            </InsertParameters>
        </asp:ObjectDataSource>
        </asp:Panel>
        <cc1:ModalPopupExtender ID="TestModalPopupExtender" runat="server" 
            TargetControlID="TestHyperLink"
            PopupControlID="Panel2" 
            BackgroundCssClass="modalBackground"  
            DropShadow="true"
            PopupDragHandleControlID="Panel2"> 
        </cc1:ModalPopupExtender>
        </ContentTemplate>
        </asp:UpdatePanel>
    </div>       
    </form>
</body>
</html>
 
'-----------------code behind document--------------------
Partial Class EditMeter
    Inherits System.Web.UI.Page
    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
 
        Dim ID As String = Right(Me.Request.QueryString.ToString, 6)
        'for testing purposes
        ID = "000013"
        ID = "007027"
        SelectedIDTextBox.Text = ID
 
    End Sub
 
    Protected Sub FrequencyRadioButtonList_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim freq As RadioButtonList = TestFormView.FindControl("FrequencyRadioButtonList")
        'I want to do some work here but the modal popup panel closes before it gets here
    End Sub
End Class

Open in new window

0
Comment
Question by:TheLakeMan
2 Comments
 

Accepted Solution

by:
TheLakeMan earned 0 total points
ID: 20331934
The problem was the position of the UpdatePanel.
UpdatePanel
       Panel
           Formview

Move the UpdatePanel inside the Panel and it performs partial page refreshes correctly.
Panel
     UpdatePanel
           Formview
0
 
LVL 1

Expert Comment

by:Vee_Mod
ID: 20342715
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question