简体   繁体   中英

opening a radwindow from a user control

How to open a radwindow on the click event of a Imagebutton within a user control? Moreover i have used the same code in aspx page and it works fine.

car.ascx

code behind car.ascx.cs

protected void btnCarLogo_Click(object sender, ImageClickEventArgs e)
{
  carurl="https://www.google.co.in/"

   ScriptManager.RegisterStartupScript(this, this.GetType(), "popCarWindow", "window.radopen('" + carurl + "', 'CarDetails');", true);
}

It has VisibleOnPageLoad property. If you set it to true , window will be visible after postback.

Examples:

Show window

myRadWindow.VisibleOnPageLoad = true;

Hide window

myRadWindow.VisibleOnPageLoad = false;

Take a look here: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx and see that the parameters are Page and not this (ie UserCOntrol).

Here is on working with JS functio nnames in user controls: http://www.telerik.com/support/kb/aspnet-ajax/general/using-dynamic-unique-names-for-javascript-functions.aspx

And, if you are going to have more than one manager on the page: http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-wrong-window-opened.html .

That way probably you get errors stating that the window is null

Try it like this: Code behind:

string script = "<script language='javascript' type='text/javascript'>Sys.Application.add_load(ShowWindow);</script>";

ClientScript.RegisterStartupScript(this.GetType(), "showWindow", script);   

Then on your aspx:

<script type="text/javascript">   
    function ShowWindow()   
    {   
        var oWnd = window.radopen('https://www.google.co.in/', 'window1');   
    }       
</script>  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM