Solved

How do I prevent AutoPostBack from closing the ModalPopupExtender Panel?

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now