2015-12-14 140 views
0

我在更新面板的Grid視圖中有多個記錄,Grid-view有ImageButton,onclick這個按鈕我正在顯示一個ModalPopupExtender來顯示選定行的細節。然後我使用關閉按鈕關閉對話框。頁面樣式在ModalPopupExtender上被點擊更新面板中的gridview中的按鈕點擊更新面板

一切工作正常,直到我打開和關閉10次模型彈出,在頁面樣式受到干擾和頁面開始看起來醜陋。當我刪除更新面板,然後一切正常,但我需要更新面板平滑的用戶界面體驗。

我的代碼如下,請儘快幫助我,我因此卡住了。暫時,我在第10次用dopostback處理這個問題,這樣用戶每次都不會刷新。

aspx code。

<asp:UpdatePanel ID="udpDocuments" runat="server" UpdateMode="Conditional"> 
    <ContentTemplate> 
     <div class="Content"> 
      <h1 class="HomePageHeading">Standard Operating Procedures, Guidelines, and Policies</h1> 
      <div class="ClearFix MarginBottom30"> 
       <div class="SeriesInformation"> 
        <h2>Series</h2> 
        <ol class="ValueList"> 
         <li>1.000 - <span>Personnel Procedures</span> 
         </li> 
         <li>2.000 - <span>Veterinary Care/Laboratory Animal Medicine</span> 
         </li> 
         <li>3.000 - <span>Animal Husbandry/Facility Operations</span> 
         </li> 
         <li>4.000 - <span>Safety</span> 
         </li> 
         <li>5.000 - <span>Technical Procedures</span> 
         </li> 
         <li>6.000 - <span>Administration</span> 
         </li> 
        </ol> 
       </div> 
       <div class="PolicyNumberAbbr"> 
        <h2>SOP/Policy Number Abbreviations</h2> 
        <ol class="ValueList"> 
         <li>P = <span>Policy</span> 
         </li> 
         <li>G = <span>Guidelines</span> 
         </li> 
         <li>B = <span>Bethesda</span> 
         </li> 
         <li>F = <span>Frederick</span> 
         </li> 
        </ol> 
       </div> 
      </div> 


      <asp:Panel ID="SearchCriteria" runat="server" DefaultButton="btnSearch"> 
       <div class="FilterWrap" style="clear: both;"> 
        <fieldset class="FnlFieldSet"> 
         <legend class="Clip">Filter SOP Listings</legend> 

         <ol class="InputFields"> 
          <li> 
           <asp:Label Text="Filter by:" runat="server" ID="lblSortOrder" AssociatedControlID="ddlSortCriteria" /> 
           <ol class="HorizontalInput"> 
            <li> 
             <asp:DropDownList ID="ddlSortCriteria" runat="server" SelectMethod="Load_Filter" 
              OnSelectedIndexChanged="ddlSortCriteria_SelectedIndexChanged" AutoPostBack="true" 
              AppendDataBoundItems="true" DataTextField="Value" DataValueField="Key"> 
             </asp:DropDownList> 

             <asp:DropDownList ID="ddlCampus" Visible="false" runat="server" SelectMethod="Load_Campus" AppendDataBoundItems="true" DataTextField="value" DataValueField="key"> 
              <asp:ListItem Text="[Select]" Value="0" /> 
             </asp:DropDownList> 

             <asp:DropDownList ID="ddlSeries" Visible="false" runat="server" SelectMethod="Load_Series" AppendDataBoundItems="true" DataTextField="Name" DataValueField="Id"> 
              <asp:ListItem Text="[Select]" Value="0" /> 
             </asp:DropDownList> 

             <dms:WatermarkTextBox ID="wmTitle" runat="server" MaxLength="60" Columns="30" WatermarkText="Title" /> 
            </li> 
            <li> 
             <span class="InputButtonWrapper HasIcon SearchIcon"> 
              <asp:Button ID="btnSearch" Text="Search" OnClick="btnSearch_Click" runat="server" /> 
             </span> 
             <asp:Button ID="btnReset" Text="Reset" OnClick="btnReset_Click" runat="server" /> 
            </li> 
           </ol> 
          </li> 
         </ol> 

        </fieldset> 
       </div> 
      </asp:Panel> 

      <dms:GridView ID="gvSOPDetails" runat="server" AllowPaging="true" PageSize="50" AllowSorting="true" DataKeyNames="Id" 
       AutoGenerateColumns="False" SelectMethod="SopListingGrid_GetItem" Width="100%" 
       OnRowCommand="gvSOPDetails_RowCommand" OnRowDataBound="gvSOPDetails_RowDataBound" 
       ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Sop"> 
       <Columns> 
        <asp:TemplateField HeaderText="SOP/Policy#" SortExpression="Number"> 
         <ItemTemplate> 
          <asp:Label ID="lblNumber" runat="server" Text='<%# Item.Number %>'></asp:Label> 
         </ItemTemplate> 
        </asp:TemplateField> 

        <asp:TemplateField HeaderText="Title" SortExpression="Title"> 
         <ItemTemplate> 
          <asp:HyperLink runat="server" ID="lnkDeleteResponderIssueImage" NavigateUrl="<%# Item.MainFileAttachment==null?string.Empty:Item.MainFileAttachment.ResourceUrl %>" CssClass="FileDownloadLink" Target="_blank" Text='<%# Item.Title %>'></asp:HyperLink> 
         </ItemTemplate> 
        </asp:TemplateField> 

        <asp:TemplateField HeaderText="Revision Number" SortExpression="RevisionNumber"> 
         <ItemTemplate> 
          <asp:Label ID="lblRevisionNumber" runat="server" Text='<%# Item.RevisionNumber %>'></asp:Label> 
         </ItemTemplate> 
        </asp:TemplateField> 



        <asp:TemplateField HeaderText="Revision Date" SortExpression="RevisionDate"> 
         <ItemTemplate> 
          <%# string.Format("{0:d}", Item.RevisionDate)%> 
         </ItemTemplate> 
        </asp:TemplateField> 
        <asp:TemplateField HeaderText="Effective Date" SortExpression="EffectiveDate"> 
         <ItemTemplate> 
          <%# string.Format("{0:d}", Item.EffectiveDate)%> 
         </ItemTemplate> 
        </asp:TemplateField> 
        <asp:TemplateField HeaderText="Campus" SortExpression="LocationId"> 
         <ItemTemplate> 
          <%# Dms.Framework.Extensions.EnumExtensions.Description(Item.LocationId) %> 
         </ItemTemplate> 
        </asp:TemplateField> 

        <asp:TemplateField HeaderText="Attachments" ItemStyle-HorizontalAlign="center"> 
         <ItemTemplate> 
          <asp:ImageButton ID="imgBtnViewAttachment" runat="server" CommandName="ViewAttachment" 
           Enabled="true" CommandArgument='<%# Item.Id %>' 
           Text="Delete" ImageUrl="~/Media/Images/modal-open-icon.png" /> 
         </ItemTemplate> 
        </asp:TemplateField> 
       </Columns> 
       <EmptyDataTemplate> 
        No records match your search criteria. 
       </EmptyDataTemplate> 
      </dms:GridView> 
     </div> 

     <div> 
      <%-- OnCancelScript="__doPostBack('Ok','')" is added to fix the issue when you open the model popup 10 times and on 11th time it mashed up the UI--%> 
      <asp:Button ID="btnShowModelPopup" runat="server" Text="Button" CssClass="HideModelPopupButton" /> 
      <asp:HiddenField ID="hfSelectedSOP" runat="server" /> 
      <cc1:ModalPopupExtender ID="mpeAttachments" runat="server" 
       CancelControlID="imgBtnPopupClose" 
       TargetControlID="btnShowModelPopup" PopupControlID="pnlAttachmentsForSelectedSOP" 
       PopupDragHandleControlID="PopupHeader" Drag="true" 
       OnCancelScript="OnCloseButtonClientClick()" 
       RepositionMode="RepositionOnWindowResizeAndScroll" 
       BackgroundCssClass="ModalPopupBG"> 
      </cc1:ModalPopupExtender> 

      <asp:Panel ID="pnlAttachmentsForSelectedSOP" Style="display: none" runat="server"> 
       <div> 
        <div class="PopupHeader"> 
         <asp:ImageButton ID="imgBtnPopupClose" CssClass="ModalCloseButton" runat="server" ImageUrl="~/Media/Images/modal-close-icon.png" /> 
        </div> 
        <div class="PopupBody"> 
         <div class="PopupTitle"> 
          <asp:Label ID="lblTitle" runat="server"></asp:Label> 
          <span>attachments</span> 
         </div> 

         <asp:Panel ID="pnlSupportingAttachments" runat="server"> 
          <ul> 
           <asp:ListView runat="server" ID="lvSupportingAttachments" DataKeyNames="Id" ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Attachment" 
            SelectMethod="LoadModelPopupAttachment"> 
            <ItemTemplate> 
             <li> 
              <span> 
               <asp:HyperLink runat="server" ID="lnkDeleteResponderIssueImage" NavigateUrl="<%# Item.ResourceUrl %>" CssClass="FileDownloadLink" Target="_blank" Text='<%# Item.FileName %>'></asp:HyperLink> 
              </span> 
             </li> 
            </ItemTemplate> 
           </asp:ListView> 
          </ul> 
         </asp:Panel> 
        </div> 
       </div> 
      </asp:Panel> 
     </div> 
    </ContentTemplate> 
</asp:UpdatePanel> 



<asp:HiddenField ID="closeCount" ClientIDMode="Static" Value="0" runat="server" /> 
<script type="text/javascript"> 
    var count = 0; 
    function OnCloseButtonClientClick() { 
     if (count == 8) { 
      //__doPostBack('Ok', ''); 
      count = 0; 
     } 
     else { 
      count = count + 1; 
     } 
     return false; 
    } 
</script> 


protected void gvSOPDetails_RowCommand(object sender, GridViewCommandEventArgs e) 
    { 
     if (e.CommandName == "ViewAttachment") 
     { 
      hfSelectedSOP.Value = (string)e.CommandArgument; 
      mpeAttachments.TargetControlID = "btnShowModelPopup"; 
      lvSupportingAttachments.DataBind(); 
      mpeAttachments.Show(); 

    } 
    } 

回答

0

GOT溶液,它是隻有大約圍繞更新面板移動代碼: ASPX代碼:

  <dms:GridView ID="gvSOPDetails" runat="server" AllowPaging="true" PageSize="50" AllowSorting="true" DataKeyNames="Id" 
       AutoGenerateColumns="False" SelectMethod="SopListingGrid_GetItem" Width="100%" 
       OnRowCommand="gvSOPDetails_RowCommand" OnRowDataBound="gvSOPDetails_RowDataBound" 
       ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Sop"> 
       <Columns> 
        <asp:TemplateField HeaderText="SOP/Policy#" SortExpression="Number"> 
         <ItemTemplate> 
          <asp:Label ID="lblNumber" runat="server" Text='<%# Item.Number %>'></asp:Label> 
         </ItemTemplate> 
        </asp:TemplateField> 


        <asp:TemplateField HeaderText="Attachments" ItemStyle-HorizontalAlign="center"> 
         <ItemTemplate> 
          <asp:ImageButton ID="imgBtnViewAttachment" runat="server" CommandName="ViewAttachment" 
           Enabled="true" CommandArgument='<%# Item.Id %>' 
           Text="Delete" ImageUrl="~/Media/Images/modal-open-icon.png" /> 
         </ItemTemplate> 
        </asp:TemplateField> 
       </Columns> 
       <EmptyDataTemplate> 
        No records match your search criteria. 
       </EmptyDataTemplate> 
      </dms:GridView> 
     </div> 
    </ContentTemplate> 
</asp:UpdatePanel> 


<asp:Panel ID="pnlAttachmentsForSelectedSOP" Style="display: none" runat="server"> 
    <div> 
     <div class="PopupHeader"> 
      <asp:ImageButton ID="imgBtnPopupClose" CssClass="ModalCloseButton" runat="server" ImageUrl="~/Media/Images/modal-close-icon.png" /> 
     </div> 
     <div class="PopupBody"> 
      <div class="PopupTitle"> 
       <asp:Label ID="lblTitle" runat="server"></asp:Label> 
       <span>attachments</span> 
      </div> 
      <asp:UpdatePanel ID="upAttachmentList" runat="server" UpdateMode="Conditional"> 
       <ContentTemplate> 
        <asp:Panel ID="pnlSupportingAttachments" runat="server"> 
         <ul> 
          <asp:ListView runat="server" ID="lvSupportingAttachments" DataKeyNames="Id" ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Attachment" 
           SelectMethod="LoadModelPopupAttachment"> 
           <ItemTemplate> 
            <li> 
             <span> 
              <asp:HyperLink runat="server" ID="lnkDeleteResponderIssueImage" NavigateUrl="<%# Item.ResourceUrl %>" CssClass="FileDownloadLink" Target="_blank" Text='<%# Item.FileName %>'></asp:HyperLink> 
             </span> 
            </li> 
           </ItemTemplate> 
          </asp:ListView> 
         </ul> 
        </asp:Panel> 
       </ContentTemplate> 
      </asp:UpdatePanel> 
     </div> 
    </div> 
</asp:Panel> 
<asp:Button ID="btnShowModelPopup" runat="server" Text="Button" CssClass="HideModelPopupButton" /> 
<asp:HiddenField ID="hfSelectedSOP" runat="server" /> 
<cc1:ModalPopupExtender ID="mpeAttachments" runat="server" 
    CancelControlID="imgBtnPopupClose" 
    TargetControlID="btnShowModelPopup" PopupControlID="pnlAttachmentsForSelectedSOP" 
    PopupDragHandleControlID="PopupHeader" Drag="true" 
    RepositionMode="RepositionOnWindowResizeAndScroll" 
    BackgroundCssClass="ModalPopupBG"> 
</cc1:ModalPopupExtender> 

ASPX.cs:代碼:

protected void gvSOPDetails_RowCommand(object sender, GridViewCommandEventArgs e) 
    { 
     if (e.CommandName == "ViewAttachment") 
     { 
      hfSelectedSOP.Value = (string)e.CommandArgument; 
      mpeAttachments.TargetControlID = "btnShowModelPopup"; 
      lvSupportingAttachments.DataBind(); 
      upAttachmentList.Update(); 
    mpeAttachments.Show();    
    } 
    }