radMenu and popup windows changing focus

7 posts, 0 answers
  1. Ken De Vries
    Ken De Vries avatar
    24 posts
    Member since:
    Mar 2010

    Posted 18 Feb 2011 Link to this post

    I just upgraded my rad controls for AJAX.

    I have a GridView with a radMenu embedded in it.  it uses the following code to popup a window...

    RadMenuItem DetailsMI = new RadMenuItem("Properties", string.Empty);
    DetailsMI.ImageUrl = "images/Details.gif";
    DetailsMI.Attributes["onclick"] = string.Format("javascript:PT_ViewPage('{0}'); return(false);", DetailsURL.ToURL());
    Menu.Items.Add(DetailsMI);

    The JavaScript PT_ViewPage looks like this...

    function PT_ViewPage(TargetURL) {
        WindowArray[WindowArray.length] = window.open(TargetURL, "", "width=900, height=800, status=no, scrollbars=yes, resizable=yes");
    }

    Nothing fancy here.  The problem is that before the Teleric update, the child window that is opened used to remain on top - it retained focus.  After the update, focus shifts back to the parent window.

    My question is:  What changed and how do I get the windows to behave like it used to???
  2. Ken De Vries
    Ken De Vries avatar
    24 posts
    Member since:
    Mar 2010

    Posted 18 Feb 2011 Link to this post

    Sorry, it is a radContextMenu.  Here is the ASPX markup...

    <asp:TemplateField ShowHeader="false"  ItemStyle-Width="5%"  ItemStyle-HorizontalAlign="Right">
          <ItemTemplate>
            <asp:Image ID="btnPopup" runat="server" ImageUrl="images/Expand.jpg"   />
            <telerik:RadContextMenu 
                ID="mnuRow" 
                runat="server" 
                OnItemClick="ControlContextMenu_Click" 
                OnClientItemClicking="OnDeleteItemClicking" 
                CollapseAnimation-Duration="100" 
                ExpandAnimation-Duration="100" 
                ExpandDelay="0" 
                >
            <Targets>
                <telerik:ContextMenuControlTarget ControlID="btnPopup" />
            </Targets>
            </telerik:RadContextMenu>
        </ItemTemplate>
        </asp:TemplateField>    
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 23 Feb 2011 Link to this post

    Hello Ken De Vries,

    I tried to reproduce the issue that you encounter but with no success. Can you send us a sample running project with the problem that you describe?

    Kind regards,
    Kate
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  5. Jay
    Jay avatar
    86 posts
    Member since:
    Nov 2007

    Posted 16 Oct 2012 Link to this post

    Has this been answered? I am hitting the same problem ... setting the .Attributes["onclick"] = "open some popup" ...   causes the popup to not get focus. It seems like the focus shifts back to the parent window ... effectively hiding the popup window.

    Is there a workaround to this behavior (I simply want a RadMenuItem to open a popup when clicked).

    Thanks
  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Oct 2012 Link to this post

    Hi,

    I suppose you want to open a radwindow on clicking menu item. Here is the sample code.
    C#:
    protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
    {
        if (e.Item.Text == "open")
        {
            string script = "function f(){$find(\"" + RadWindow1.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "key", script, true);
        }
    }

    Thanks,
    Princy.
  7. Jay
    Jay avatar
    86 posts
    Member since:
    Nov 2007

    Posted 17 Oct 2012 Link to this post

    I am actually just trying to run some JavaScript to do a window.open. Your sample looks like a server post-back. Is there a way to simply run JavaScript to do a window.open without using postbacks and without the RadMenu control "stealing focus" after the JS runs?
    Thanks
  8. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Oct 2012 Link to this post

    Hi,

    You can try the following client side approach.
    JS:
    function OnClientItemClicked(sender, args) {
        if (args.get_item().get_text() == "open")
          {
        var window = $find('<%= RadWindow1.ClientID %>').show();
        }
    }

    Thanks,
    Princy.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017