Solved

How do I prevent AutoPostBack from closing the ModalPopupExtender Panel?

Posted on 2007-11-20
2
3,960 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

778 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