2012-07-12 30 views
0

我的webapp(用ASP.NET編寫)是用MasterPages佈局的。在主頁面的內容區域中,我是顯示頁面的iframe。在導航上單擊我簡單設置ContentUrl(在contentplaceholder內)到一個新的url,並刷新內容區域。刷新ContentPlaceHolder使用javascript

下面是確實的方法:

Protected Sub radprojecttree_NodeClick(sender As Object, e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles radprojecttree.NodeClick 
    Dim ts As String = e.Node.Attributes("contentpage") 
    radpancontentholder.ContentUrl = ts 
    If (Not SiteUser Is Nothing) Then 
     BSRMaster.navtree.NavTree_InitNodes(Nothing, e.Node) 
    End If 
End Sub 

但我還需要在某些時候在JavaScript中設置的contentURL和顯示頁面。但是,當我設置ContentUrl頁面不顯示。如何刷新JavaScript中的contentplaceholder?

下面是我對JavaScript至今代碼:頁面完全加載之前被稱爲

function goToPage(){ 
    var strLoc = ""; 

    switch (AutoExpandOption) { 
     case "RestoreLastNode" : 
      strLoc = readCookie(strUser + 'LastPageLocation'); 
      if ((typeof(strLoc) == "undefined") || (strLoc == null)) { 
       strLoc = 'Secure/TaskManager.aspx'; 
       createCookie(strUser + 'LastPageLocation', 'TaskManager.aspx', 100); 
      } 
      break; 

     case "GoToTaskManager" : 
      strLoc = 'Secure/TaskManager.aspx'; 
      break; 

     case "GoToDashboard" : 
      strLoc = 'Secure/Dashboards.aspx'; 
      break; 

    } 
    if (strLoc != "") { 
     var ph = $find('ctl00_radpancontentholder'); 
     ph._contentUrl = strLoc; 
     //document.getElementById('pagecontentframe').src = strLoc; 
    } 
} 
+0

你的註釋行應該工作,我相信。您是否肯定該函數正在被調用並且源代碼是否正確?我會建議嘗試在控制檯中執行實時測試。最初的src是否有效?也許你需要一些額外的信息到src(比如http:// localhost /)。在更新之前,請執行console.log(document.getElementById(「pagecontentframe」)。src); – EricG 2012-07-12 22:57:34

回答

0

$發現,因此沒有控件存在