3

Objective:- From the server-side, I need to open a radwindow(defined in JavaScript of the aspx page) automatically on an IF condition.

Code used:-

In aspx page, I defined the radwindow as:-

<telerik:RadWindowManager Skin="WBDA" ID="AssetPreviewManager" Modal="true" 
EnableEmbeddedSkins="false" runat="server"  DestroyOnClose="true" Behavior="Close" 
style="z-index:8000">
    <Windows>   
        <telerik:RadWindow ID="DisclaimerAlertWindow" runat="server" Width="720px"    Height="220px" 
Modal="true" visibleStatusbar="false" VisibleTitlebar="false" keepInScreenBounds="true" title="Sourav">                                            
      </telerik:RadWindow>  
   </Windows>  
</telerik:RadWindowManager>

In JavaScript, a function is defined for opening the radwindow:-

function openRadWindow() 
     { 
        var oWnd = radopen('DisclaimerAlert.aspx, 'DisclaimerAlertWindow'); 
        oWnd.set_title('Access Denied !');  
        oWnd.Center(); 
        return false; 
     }

So on the server side of the aspx page, In the Page Load event an IF condition is checked and then I'm calling 'openRadWindow()' function as:-

protected void Page_Load(object sender, EventArgs e)
{
if (fieldValue == "False") 
{ 
 string xyz = "<script type='text/javascript' lang='Javascript'>openRadWindow();</script>"; 
 ClientScript.RegisterStartupScript(this.GetType(), "Window", xyz); 
}
}

Problem:-

But on running this, these JavaScript errors are coming:-

  1. Object doesn't support this property or method.
  2. 'undefined' is null or not an object

Please help how to achieve my objective. I am totally stuck.

4

2 に答える 2

2

こちらをご覧ください。ScriptManager.RegisterStartupScript メソッドの使用方法が説明されています: http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-javascript-from-server-side.html。ScriptManager のメソッドに注意してください。また、Sys.Application.Load イベントを調べて、コードの実行が早すぎるのを防ぎます。

于 2012-10-23T14:11:32.793 に答える