How Open RadWindow Popup on Button Click Handler

9 posts, 0 answers
  1. Ravi Kumar
    Ravi Kumar avatar
    37 posts
    Member since:
    May 2010

    Posted 27 Jul 2010 Link to this post

    Hi,

    I have user control, in which  have "Add" button. now i,m calling this user control in my page and firing click event of Add button (which is in the user control)

           protected void Page_Init(object sender, EventArgs e)
            {
                HeaderToolBar1.Add_Event += new WFSite.ViewControls.HeaderToolBar.AddDelegate(HeaderToolBar1_Add_Event);
              }

            void HeaderToolBar1_Add_Event(object sender, RadToolBarEventArgs e)
            {
               // How to open radwindow popup
            }


    Thank you
    Ravi
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Jul 2010 Link to this post

    Hello Aravind,

    You can open the RadWindow from the server by setting its VisibleOnPageLoad property to true.

    C#:

    RadWindowManager windowManager = new RadWindowManager();  
    RadWindow widnow1 = new RadWindow();  
    // Set the window properties  
    widnow1.NavigateUrl = "Window1.aspx";  
    widnow1.ID = "RadWindow1";  
    widnow1.VisibleOnPageLoad = true; // Set this property to True for showing window from code  
    windowManager.Windows.Add(widnow1);  
    this.form1.Controls.Add(widnow1);

    More information on the subject is available here:

    http://www.telerik.com/help/aspnet-ajax/window_settingserversideproperties.html

    -Shinu.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ravi Kumar
    Ravi Kumar avatar
    37 posts
    Member since:
    May 2010

    Posted 27 Jul 2010 Link to this post

    Hi Shinu

    Thanks for reply.

    User Control (HTML):
    <telerik:RadToolBar ID="RadToolBar1" runat="server" Height="26px" Width="100%" OnButtonClick="RadToolBar1_ButtonClick">
        <Items>
            <telerik:RadToolBarButton runat="server" ImageUrl="~/Images/TLB_ADDNEW_16.gif" Text="<%$ Resources:PDICulture, htbControlAdd %>"
                ToolTip="<%$ Resources:PDICulture, htbControlToolTipAdd %>">
            </telerik:RadToolBarButton>
        </Items>
    </telerik:RadToolBar>

    User Control Code Behind:

     public delegate void AddDelegate(object sender, RadToolBarEventArgs e);
     public event AddDelegate Add_Event;

      protected void RadToolBar1_ButtonClick(object sender, Telerik.Web.UI.RadToolBarEventArgs e)
       {
           Add_Event(sender, e);
         }


    Content Page in which i,m using user control

    void HeaderToolBar1_Add_Event(object sender, RadToolBarEventArgs e)
            {
               // How to open radwindow popup
               RadWindowManager windowManager = new RadWindowManager();
                RadWindow widnow1 = new RadWindow();
                // Set the window properties   
                widnow1.NavigateUrl = "DateDialog.aspx";
                widnow1.ID = "RadWindow1";
                widnow1.VisibleOnPageLoad = false; // Set this property to True for showing window from code   
                windowManager.Windows.Add(widnow1);
                this.Controls.Add(widnow1);
            }

    Its not working at my end. Can you see whats going wrong.

    Thank you
    Ravi

     
  5. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 27 Jul 2010 Link to this post

    Hello Ravi,

    In your code you:
    1. Create a RadWindowManager
    2. Create a RadWindow
    3. Set RadWindow's properties
    4. Add RadWindow to RadWindowManager's collection.

    You don't add the manager to the page however. I would also recommend to add the controls not directly to the page, but to the form or better - to a placeholder inside that form.


    Sincerely yours,
    Georgi Tunev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Ravi Kumar
    Ravi Kumar avatar
    37 posts
    Member since:
    May 2010

    Posted 28 Jul 2010 Link to this post


    Thanks for reply

    its working fine now. you are rock!!!

    Thank you
    Ravi
  7. Robert Smith
    Robert Smith avatar
    3 posts
    Member since:
    Oct 2012

    Posted 29 Jul 2010 Link to this post

    Ravi,

    I'm having same problem but i have not figured out the fix.  Can you please post your final code that fixed for you?

  8. Ravi Kumar
    Ravi Kumar avatar
    37 posts
    Member since:
    May 2010

    Posted 02 Aug 2010 Link to this post

    Hi,
    You can use


     protected void btnMESetPassword_OnClick(object sender, EventArgs e)
            {
                RadAjaxManager1.ResponseScripts.Add("openRadWindow()");
            }

     function openRadWindow()
            {
                 var firstName = $("#<%= txtMEFirst.ClientID %>").val();
                 var middleName = $("#<%= txtMEMiddleInitial.ClientID %>").val();
                 var lastName = $("#<%= txtMELast.ClientID %>").val();
                 var employeeid = $("#<%= txtMEEmployeeProfileID.ClientID %>").val();
                 var name = employeeid + ' - ' + firstName +' ' + middleName + ' ' + lastName;
                 var oWnd = radopen("SetPasswordDialog.aspx?EmployeeName=" + name, "PasswordWindow");
           
            }
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
            <Windows>
    <telerik:RadWindow Modal="true" Width="400px" Height="200px" Behaviors="Move, Close"
                    ReloadOnShow="true" ID="PasswordWindow" runat="server" VisibleStatusbar="true"
                    NavigateUrl="SetPasswordDialog.aspx" OnClientClose="OnClientCloseSetPassword" />
            </Windows>
    </telerik:RadWindowManager>

    -Ravi
  9. Rohan
    Rohan avatar
    94 posts
    Member since:
    Jul 2012

    Posted 28 Nov 2012 Link to this post

    Hi all,

    I want to open the radwindow on delegate event ,i try this code

      RadWindow window1 = new RadWindow();
                window1.NavigateUrl = "http://www.google.com";
                window1.VisibleOnPageLoad = true;
                window1.Width = 500;
                window1.Height = 300;
                this.Controls.Add(window1);

    but it doesn't work ...please provide any snap or document
  10. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1492 posts

    Posted 30 Nov 2012 Link to this post

    Hi Rohan,

    А possible scenario in your case could be that you are ajaxifying some part of the page and the form is not updated. You have to add the window object to the form not just to the page. Please refer to this article which will shed more light on how to open RadWindow from the server.

    All the best,
    Danail Vasilev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017