使用javascript刷新ContentPlaceHolder
我的webapp(用ASP.NET编写)是用母版页布局的。在母版页的内容区域中,是一个iframe,用于显示页面。在导航时,单击我简单地将ContentUrl(在contentplaceholder中)设置为新url,它将刷新内容区域 以下是实现此目的的方法:使用javascript刷新ContentPlaceHolder,javascript,asp.net,master-pages,contentplaceholder,Javascript,Asp.net,Master Pages,Contentplaceholder,我的webapp(用ASP.NET编写)是用母版页布局的。在母版页的内容区域中,是一个iframe,用于显示页面。在导航时,单击我简单地将ContentUrl(在contentplaceholder中)设置为新url,它将刷新内容区域 以下是实现此目的的方法: Protected Sub radprojecttree_NodeClick(sender As Object, e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles radprojecttr
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;
}
}
$find在页面完全加载之前被调用,因此没有控件存在我相信您的注释行应该可以工作。您是否确定函数正在被调用且源代码正确?我建议尝试在控制台中执行实时测试。初始src有效吗?也许你需要一些额外的信息给src(比如)。在更新之前,执行console.log(document.getElementById(“pagecontentframe”).src);