RadToolBar and RadWindow Integration Using CodeBehind

3 posts, 1 answers
  1. Ahmed
    Ahmed avatar
    2 posts
    Member since:
    Sep 2012

    Posted 25 Sep 2012 Link to this post

    Hi All,

    Is it possible to popup a RadWindow when a RadToolBarButton is clicked in code behind.
    I'm tried to do this by passing by a javascript function and then call the VB.NET function but it didn't work
    Here's my code :

    ASPX:
            <telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
                <script type="text/javascript">
                    var toolbar;
                    var ajaxManager;
     
                    function pageLoad() {
                        toolbar = $find("<%= RadToolBarApplication.ClientID %>");
                        ajaxManager = $find("<%=RadAjaxManager1.ClientID %>");
                    }
                    function onButtonClicked(sender, args) {
                        var commandName = args.get_item().get_commandName();
                        if (commandName == "functionJS") {
                            PageMethods.VBFunction()
                        }
                    }
                </script>
            </telerik:RadScriptBlock>
     
    ....
     
    <telerik:RadToolBar ID="RadToolBarApplication" runat="server" OnClientButtonClicked="onButtonClicked" >
           <Items>
               <telerik:RadToolBarButton Text="button1" CommandName="functionJS" />
           </Items>
    </telerik:RadToolBar>

    Code-Behind:
    <System.Web.Services.WebMethod()> Public Sub VBFunction()
        Dim radWindow As New RadWindow
        radWindow.ID = "RadWindow8"
        radWindow.AutoSize = True
        radWindow.VisibleOnPageLoad = True
        RadWindowManager1.Windows.Add(radWindow)
        Me.form1.Controls.Add(radWindow)
    End Sub

    Thanks
    Ahmed


  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 26 Sep 2012 Link to this post

    Hi Ahmed,

    Try the following code to achieve your scenario.

    ASPX:
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" >
     <Windows>
        <telerik:RadWindow ID="RadWindow1" NavigateUrl="Window.aspx" runat= "server"></telerik:RadWindow>
     </Windows>
    </telerik:RadWindowManager>

    VB:
    Protected Sub RadToolBarApplication_ButtonClick(sender As Object, e As Telerik.Web.UI.RadToolBarEventArgs)
        Dim btn As RadToolBarButton = TryCast(e.Item, RadToolBarButton)
        If btn.CommandName.ToString() = "functionJS" Then
            Dim script As String = "function f(){$find(""" + RadWindow1.ClientID + """).show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
            ScriptManager.RegisterStartupScript(Page, Page.[GetType](), "RadWindow", script, True)
        End If
    End Sub

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ahmed
    Ahmed avatar
    2 posts
    Member since:
    Sep 2012

    Posted 26 Sep 2012 Link to this post


    Thanks Princy
Back to Top