2012-04-10 84 views
1

我有一個帶有超鏈接的GridView,並在超鏈接上點擊一個Modal Popup Extender彈出。有些文本框是基於GridView被點擊的行顯示或隱藏的。我的問題是當Modal彈出窗口和用戶填寫了texbox並讓他們說關閉時,我們隱藏Modal Popup Extender,當他們點擊不同的GridView行或者之前的數據出現在同一行上時。似乎Modal Popup Extender不會清除它下面的控件。我試着將UpdatePanel設置爲條件並強制更新不起作用。請幫助我一直試圖解決這個問題,現在幾天,它變得非常討厭。謝謝你的幫助。清除控件在modalpopupetentender

<asp:UpdatePanel ID="upGrid" runat="server" UpdateMode="Conditional"> 
<ContentTemplate> 
<div>  
      <asp:GridView 
        ID="gvReports" 
        runat="server" 
        CssClass="gridview" 
        RowStyle-CssClass="gridview_itm" 
        AlternatingRowStyle-CssClass="gridview_aitm" 
        HeaderStyle-CssClass="gridview_hdr" 
        PagerStyle-CssClass="gridview_pgr" 
        AutoGenerateColumns="False" 
        Width="100%" onrowcommand="gvReports_RowCommand">     
        <Columns> 
        <asp:TemplateField HeaderText="Name">      
         <ItemTemplate>       
          <asp:LinkButton ID="btnReport" runat="server" CommandName="Report" CommandArgument='<%#Eval("n_ReportFileName")%>' Text='<%#Eval("n_Name")%>' CausesValidation="false"></asp:LinkButton> 
         </ItemTemplate> 
        </asp:TemplateField> 
        <asp:TemplateField HeaderText="Description">      
         <ItemTemplate>       
          <%#Eval("n_Description")%> 
         </ItemTemplate> 
        </asp:TemplateField> 
        </Columns> 
      </asp:GridView> 
      <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button1" PopupControlID="ReportParameterPanel" BackgroundCssClass="modalBackground" DropShadow="True" />     
      <asp:Button ID="Button1" runat="server" Text="Button" style="visibility:hidden"/> 
      <asp:Panel ID="ReportParameterPanel" runat="server" Height="375px"      
       Width="700px" BackColor="#f4de90" 
       HorizontalAlign="Center" BorderColor="#666666" BorderStyle="Outset" 
       BorderWidth="5px"> 
       <table style="height: 50px; width: 685px; text-align: left"> 
        <span id="lblReportName" runat="server" style="font-weight:bold; font-size:larger"></span> 
        <tr> 
         <td align="left" style="padding-left: 5px; width: 335px;" valign="top"> 
          <span id="StarDateStar" runat="server" style="color: Red">*Optional&nbsp;</span><span id="lblStartDate" runat="server">Start Date: </span> 
          <asp:TextBox ID="tbStartDate" runat="server"></asp:TextBox> 
          <asp:ImageButton ID="imgCalendar" runat="server" ImageUrl="~/App_Themes/Sugar2006/images/Calendar_scheduleHS.png" ImageAlign="Middle" /> 
          <asp:CalendarExtender ID="ceStartDate" runat="server" TargetControlID ="tbStartDate" PopupButtonID="imgCalendar" />   
          <asp:MaskedEditExtender ID="mexStartDate" runat="server" 
           TargetControlID="tbStartDate" 
           Mask="99/99/9999" 
           MaskType="Date" 
           MessageValidatorTip="true" 
           OnFocusCssClass="MaskedEditFocus" 
           OnInvalidCssClass="MaskedEditError" /> 
           <br /> 
          <asp:MaskedEditValidator ID="mevStartDate" runat="server" 
           ControlToValidate="tbStartDate" 
           ControlExtender="mexStartDate" 
           Display="Dynamic" 
           InvalidValueMessage="This date is invalid!" Font-Bold="True" 
           ForeColor="#D50000" ValidationGroup="vgMyGroup" /> 
         </td> 
         <td align="left" style="padding-right: 5px; padding-bottom: 5px; width: 350px;" valign="top"> 
          <span id="EndDateStar" runat="server" style="color: Red">*Optional&nbsp;</span><span id="lblEndDate" runat="server">End Date: </span> 
          <asp:TextBox ID="tbEndDate" runat="server"></asp:TextBox> 
          <asp:ImageButton ID="imgCalendar2" runat="server" ImageUrl="~/App_Themes/Sugar2006/images/Calendar_scheduleHS.png" ImageAlign="Middle" /> 
          <asp:CalendarExtender ID="ceEndDate" runat="server" TargetControlID ="tbEndDate" PopupButtonID="imgCalendar2" />   
          <asp:MaskedEditExtender ID="mexEndDate" runat="server" 
           TargetControlID="tbEndDate" 
           Mask="99/99/9999" 
           MaskType="Date" 
           MessageValidatorTip="true" 
           OnFocusCssClass="MaskedEditFocus" 
           OnInvalidCssClass="MaskedEditError" /> 
           <br /> 
          <asp:MaskedEditValidator ID="mevEndDate" runat="server" 
           ControlToValidate="tbEndDate" 
           ControlExtender="mexEndDate" 
           Display="Dynamic" 
           InvalidValueMessage="This date is invalid!" Font-Bold="True" 
           ForeColor="#D50000" 
           ValidationGroup="vgMyGroup" /> 
         </td> 
        </tr> 
       </table>                 
       <asp:Button ID="btnClose" runat="server" Text="Close" CssClass="btn" onclick="btnClose_Click" CausesValidation="false" /> 
       <asp:Button ID="btnSend" runat="server" Text="Report" CssClass="btn" OnClick="btnSend_Click" Enabled="false" CausesValidation="true" ValidationGroup="vgMyGroup" />      
      </asp:Panel> 
       </div> 
</ContentTemplate> 
<Triggers> 
    <asp:PostBackTrigger ControlID="btnSend" /> 
</Triggers> 
</asp:UpdatePanel> 

回答

0

嘗試從代碼隱藏調用modalpopupextender:

ModalPopupExtender1.Show(); 
+0

這是我在用從背後的代碼,也隱藏它從代碼後面,但它不起作用。 – 2012-04-10 14:34:08

+0

我已經在上面發佈了代碼。 – 2012-04-10 14:42:37

+0

嘗試在調用ModalPopupExtender1.Show()之前保留updatepanel(child)中的ModalPopup並刷新/更新; – 2012-04-10 17:20:31

0

使用了LinkBut​​ton,而不是和點擊清除在modalpopup控件,然後調用ModalPopup.Show()

+0

2012-04-10 14:36:42

+0

這就是我如何初始化ModalPopupExtender,然後我從後面的代碼調用ModalPopupExtender1.show(),我也隱藏它後面的代碼,但它仍然保持以前的值。 – 2012-04-10 14:37:33

+0

我上面已經發布了代碼。 – 2012-04-10 14:42:42