2013-07-12 1 views
0

그래서 여기에 시나리오가 있습니다. 일부 데이터를로드하는 webpart가 있습니다. 나는 페이지의 다른 위치에 팝업을 열고, 사용자가 해당 페이지에서 (동작 만들기) 무언가를하면 팝업이 닫히고 호출 페이지가 다시로드됩니다.웹 파트 수명주기의 데이터로드가 처음에는 작동하지만 팝업 리로드에서는 새로 고침하지 않습니다.

이렇게되면 브라우저에서 페이지가 다시로드되지만 웹 파트에 내 새 데이터가 표시되지 않음을 알 수 있습니다.

자식 컨트롤 만들기에서 데이터를 바인딩하는 중입니다. 페이지로드시에 작업을 시도했지만 작동하지 않았습니다. 주소 표시 줄에 커서를 놓으면 새 데이터가 표시되지만 F5 키를 누르면 커서가 사라집니다.

public class LastCreatedJobs : WebPart 
    { 
     private GridView _lastCreatedJobsGrid; 

     protected override void CreateChildControls() 
     { 
      base.CreateChildControls(); 
      CreateGridControl(); 
     } 

     private void CreateGridControl() 
     { 
      try 
      { 
       _lastCreatedJobsGrid = new GridView(); 
       _lastCreatedJobsGrid.RowDataBound += _lastCreatedJobsGrid_RowDataBound; 

       var bJobCode = new BoundField { DataField = "JobCode", HeaderText = "Job Code" }; 
       bJobCode.ItemStyle.CssClass = "ms-cellstyle ms-vb2"; 
       bJobCode.HeaderStyle.CssClass = "ms-vh2"; 
       _lastCreatedJobsGrid.Columns.Add(bJobCode); 

       var jobName = new HyperLinkField 
       { 
        DataNavigateUrlFields = new[] { "JobWebsite" }, 
        HeaderText = "Job Name", 
        DataTextField = "JobName" 
       }; 
       jobName.ItemStyle.CssClass = "la"; 
       jobName.HeaderStyle.CssClass = "ms-vh2"; 
       jobName.ControlStyle.CssClass = "ms-listlink"; 
       _lastCreatedJobsGrid.Columns.Add(jobName); 

       var biPowerLink = new HyperLinkField 
       { 
        Target = "_blank", 
        DataNavigateUrlFields = new[] { "IPowerLink" }, 
        HeaderText = "iP Link", 
        Text = @"<img src='" + ResolveUrl("/_layouts/15/PWC/DMS/Images/iclient.gif") + "' /> " 
       }; 
       biPowerLink.ItemStyle.CssClass = "ms-cellstyle ms-vb-icon"; 
       biPowerLink.HeaderStyle.CssClass = "ms-vh2"; 
       _lastCreatedJobsGrid.Columns.Add(biPowerLink); 

       _lastCreatedJobsGrid.CssClass = "ms-listviewtable"; //Table tag? 
       _lastCreatedJobsGrid.HeaderStyle.CssClass = "ms-viewheadertr ms-vhlt"; 
       _lastCreatedJobsGrid.RowStyle.CssClass = "ms-itmHoverEnabled ms-itmhover"; 

       _lastCreatedJobsGrid.AutoGenerateColumns = false; 

       _lastCreatedJobsGrid.EmptyDataText = Constants.Messages.NoJobsFound; 

       Controls.Add(_lastCreatedJobsGrid); 
       LoadGridData(); 
      } 
      catch (Exception ex) 
      { 
       LoggingService.LogError(LoggingCategory.Job, ex); 
      } 
     } 

     private void _lastCreatedJobsGrid_RowDataBound(object sender, GridViewRowEventArgs e) 
     { 
      try 
      { 
       if (e.Row.RowType == DataControlRowType.DataRow) 
       { 
        JobInfo jobInfo = (JobInfo)e.Row.DataItem; 

        if (jobInfo.IsConfidential) 
        { 
         var newHyperLink = new HyperLink 
         { 
          Text = @"<img src='" + ResolveUrl("/_layouts/15/PWC/DMS/Images/spy-icon.gif") + "' /> ", 
          NavigateUrl = jobInfo.xlink 
         }; 
         e.Row.Cells[2].Controls.RemoveAt(0); 
         e.Row.Cells[2].Controls.Add(newHyperLink); 
        } 
       } 
      } 
      catch (Exception ex) 
      { 
       LoggingService.LogError(LoggingCategory.Job, ex); 
      } 
     } 

     #region Private methods 

     private void LoadGridData() 
     { 
      try 
      { 
       String currentUrl = SPContext.Current.Site.Url; 

       var jobInfoList = new List<JobInfo>(); 

       SPSecurity.RunWithElevatedPrivileges(delegate 
       { 
        using (var clientSiteCollection = new SPSite(currentUrl)) 
        { 
         foreach (
          SPWeb web in 
           clientSiteCollection.AllWebs.Where(
            c => 
            c.AllProperties[Constants.WebProperties.General.WebTemplate] != null && 
            c.AllProperties[Constants.WebProperties.General.WebTemplate].ToString() == 
            Constants.WebTemplates.JobWebPropertyName).OrderByDescending(d => d.Created).Take(5) 
          ) 
         { 
          SPList jobInfoListSp = web.Lists.TryGetList(Constants.Lists.JobInfoName); 
          if (jobInfoListSp != null) 
          { 
           if (jobInfoListSp.Items.Count > 0) 
           { 
            var value = 
             new SPFieldUrlValue(
              jobInfoListSp.Items[0][Constants.FieldNames.Job.iPowerLink].ToString()); 

            jobInfoList.Add(new JobInfo 
            { 
             JobName = jobInfoListSp.Items[0][Constants.FieldNames.Job.JobName].ToString(), 
             JobCode = jobInfoListSp.Items[0][Constants.FieldNames.Job.JobCode].ToString(), 
             xlink= value.Url, 
             JobWebsite = web.Url, 
             IsConfidential = HelperFunctions.ConvertToBoolean(jobInfoListSp.Items[0][Constants.FieldNames.Job.Confidential].ToString()) 
            }); 
           } 
          } 

          web.Dispose(); 
         } 
        } 
       }); 

       _lastCreatedJobsGrid.DataSource = jobInfoList; 
       _lastCreatedJobsGrid.DataBind(); 
      } 
      catch (Exception ex) 
      { 
       LoggingService.LogError(LoggingCategory.Job, ex); 
      } 
     } 

     #endregion 
    } 

팝업을 여는 페이지 : 버튼을 클릭 한 후

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server"> 
    <SharePoint:ScriptLink ID="ScriptLink1" runat="server" Name="sp.js" OnDemand="false" Localizable="false" LoadAfterUI="true"/> 
    <script type="text/javascript"> 
     //Just an override from the ClientField.js - Nothing Special to do here 
     function DisableClientValidateButton() { 
     } 

     function waitMessage() { 
      window.parent.eval("window.waitDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose('Creating Job','Working on the Job site. Please wait.',90,450);"); 
     } 

    </script> 
</asp:Content> 

및 버튼 클릭으로 해당 페이지의 코드 숨김, 그냥 중요한 부분.

ClientScript.RegisterStartupScript(GetType(), "CloseWaitDialog", 
               @"<script language='javascript'> 
         if (window.frameElement != null) { 
          if (window.parent.waitDialog != null) { 
window.parent.waitDialog.close();         
window.frameElement.commonModalDialogClose(1, 'New call was successfully logged.'); 

          } 
         } 
         </script>"); 

답변

0

여기 로드맵 데이터는 OnPreRender에서 실행되어야합니다.

관련 문제