locked
ASPX.NET RadToolbarButton POSTBACK ISSUE RRS feed

  • Question

  • User-441238553 posted
    I have the following 1) ASPX FILE:

    <%@
    Page Language="VB" AutoEventWireup="false" CodeFile="lastOne.aspx.vb" Inherits="Forms_lastOne" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> function OpenWindow(sID, sURL) { var oManager = GetRadWindowManager(); oManager.open(sURL, sID); return false; // var oWnd = radopen(sURL, sID); } function OnClientButtonClickingHandler(sender, eventArgs) { alert("aaaaaaaa") //eventArgs.set_cancel(true); } </script> </head> <body> <form id="form1" runat="server"> <div> <telerik:RadWindowManager EnableShadow="true" Behaviors="Close, Move" ID="m_oRadWindowManager" runat="server" Modal="true" Skin="Windows7"> <Windows> <telerik:RadWindow ID="m_oEditLocDialog" VisibleOnPageLoad="false" Title="Edit Location" VisibleStatusbar="false" NavigateUrl="~/Forms/Exports/ExportGrid.aspx" runat="server" Modal="true" Width="550" Height="500"> </telerik:RadWindow> </Windows> </telerik:RadWindowManager> <telerik:RadAjaxPanel runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> <telerik:RadButton ID="m_oEditBtn" Text="EditBtn" runat="server" OnClick="OpenWindow"> </telerik:RadButton> <telerik:RadToolBar ID="m_oOverviewToolbar" runat="server" Width="100%" EnableRoundedCorners="True" EnableShadows="True" OnButtonClick="m_oOverviewToolbar_ButtonClick" > <Items> <telerik:RadToolBarButton runat="server" Text="OpenRadWindow" CommandName="Edit"> </telerik:RadToolBarButton> <telerik:RadToolBarButton ID="i1" runat="server" CommandName="View" Text="ShowMsg" PostBack="false" > </telerik:RadToolBarButton> </Items> </telerik:RadToolBar> </telerik:RadAjaxPanel> </div> </form> </body> </html>

    2) VB CODE ( Behind Code)
    Imports Telerik.Web.UI
    
    Partial Class Forms_lastOne
        Inherits System.Web.UI.Page
        Protected Sub OpenWindow(sender As Object, e As EventArgs)
            OpenWindow(Me, m_oEditLocDialog, Nothing)
        End Sub
        Protected Sub OpenWindow(oParentCtrl As Control, oWindow As RadWindow, sURL As String)
            RadScriptManager.RegisterStartupScript(oParentCtrl, oParentCtrl.GetType(), "openWnd", String.Format("OpenWindow('{0}', '{1}');", oWindow.ID, sURL), True)
    
        End Sub
    
    
        Protected Sub m_oOverviewToolbar_ButtonClick(sender As Object, e As RadToolBarEventArgs) Handles m_oOverviewToolbar.ButtonClick
            Dim oBtn As RadToolBarButton = e.Item
            If (oBtn.CommandName = "Edit") Then
    
                OpenWindow(Me, m_oEditLocDialog, Nothing)
            ElseIf (oBtn.CommandName = "View") Then
                MsgBox("sssss")
            End If
    
        End Sub
    End Class
    <svg aria-hidden="true" class="svg-icon mln2 mr0 iconHistory" width="19" height="18" viewbox="0 0 19 18"></svg>

    I have the following 1) ASPX FILE:

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="lastOne.aspx.vb" Inherits="Forms_lastOne" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
         <script type="text/javascript">
            function OpenWindow(sID, sURL) {
                var oManager = GetRadWindowManager();
                oManager.open(sURL, sID);
                return false;
    //                var oWnd = radopen(sURL, sID);
             }
             function OnClientButtonClickingHandler(sender, eventArgs) {
                 alert("aaaaaaaa")
                     //eventArgs.set_cancel(true);
    
             }    
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                  <telerik:RadWindowManager EnableShadow="true" Behaviors="Close, Move" ID="m_oRadWindowManager"
                runat="server" Modal="true" Skin="Windows7">
                <Windows>
                    <telerik:RadWindow ID="m_oEditLocDialog" VisibleOnPageLoad="false" Title="Edit Location"
                        VisibleStatusbar="false" NavigateUrl="~/Forms/Exports/ExportGrid.aspx" runat="server" Modal="true"
                        Width="550" Height="500">
                    </telerik:RadWindow>
                </Windows>
            </telerik:RadWindowManager>
        <telerik:RadAjaxPanel runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
            <telerik:RadButton ID="m_oEditBtn" Text="EditBtn" runat="server" OnClick="OpenWindow">
            </telerik:RadButton>
            <telerik:RadToolBar ID="m_oOverviewToolbar" runat="server" Width="100%" EnableRoundedCorners="True"
                EnableShadows="True" OnButtonClick="m_oOverviewToolbar_ButtonClick" >
                <Items>
                    <telerik:RadToolBarButton runat="server" Text="OpenRadWindow" CommandName="Edit">
                    </telerik:RadToolBarButton>
                    <telerik:RadToolBarButton ID="i1" runat="server" CommandName="View" Text="ShowMsg" PostBack="false" >
                    </telerik:RadToolBarButton>
                </Items>
            </telerik:RadToolBar>
        </telerik:RadAjaxPanel>
            </div>
        </form>
    </body>
    </html>

    2) VB CODE ( Behind Code)

    Imports Telerik.Web.UI
    
    Partial Class Forms_lastOne
        Inherits System.Web.UI.Page
        Protected Sub OpenWindow(sender As Object, e As EventArgs)
            OpenWindow(Me, m_oEditLocDialog, Nothing)
        End Sub
        Protected Sub OpenWindow(oParentCtrl As Control, oWindow As RadWindow, sURL As String)
            RadScriptManager.RegisterStartupScript(oParentCtrl, oParentCtrl.GetType(), "openWnd", String.Format("OpenWindow('{0}', '{1}');", oWindow.ID, sURL), True)
    
        End Sub
    
    
        Protected Sub m_oOverviewToolbar_ButtonClick(sender As Object, e As RadToolBarEventArgs) Handles m_oOverviewToolbar.ButtonClick
            Dim oBtn As RadToolBarButton = e.Item
            If (oBtn.CommandName = "Edit") Then
    
                OpenWindow(Me, m_oEditLocDialog, Nothing)
            ElseIf (oBtn.CommandName = "View") Then
                MsgBox("sssss")
            End If
    
        End Sub
    End Class

    The Problem: When I pressing in ShowMsg button inside toolbar

    <telerik:RadToolBarButton ID="i1" runat="server" CommandName="View" Text="ShowMsg" PostBack="false" >
                    </telerik:RadToolBarButton>

    its print a message 'sssss' but its printing 2 times I disabled postback by choice postback="false" , but in this case when I pressing in this button nothing happened.

    How to prevent prinintg this message when page reloading ?

    Please any one can help me on this . Thank you in advanced .

    Monday, April 20, 2020 7:08 PM

All replies

  • User-1330468790 posted

    Hi eyadmn73,

     

    I tried your code and could not reproduce that error

    Is there any other place that you set to print the "sssss" content in the message box?

     

    You could try below code that I used to see if you still have the problem.

    What I can suggest is to comment other codes and just focus on this part.

    If the problem disappears, you could be confirmed that the code is correct and there might be other places cause this unexpected error.

    .aspx :

    <form id="form1" runat="server">
            <div>
                <telerik:RadAjaxPanel runat="server">
                    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
                    <telerik:RadToolBar ID="m_oOverviewToolbar" runat="server" Width="100%" EnableRoundedCorners="True"
                        EnableShadows="True" OnButtonClick="m_oOverviewToolbar_ButtonClick">
                        <Items>
                            <telerik:RadToolBarButton runat="server" Text="OpenRadWindow" CommandName="Edit">
                            </telerik:RadToolBarButton>
                            <telerik:RadToolBarButton ID="i1" runat="server" CommandName="View" Text="ShowMsg" PostBack="true">
                            </telerik:RadToolBarButton>
                        </Items>
                    </telerik:RadToolBar>
                </telerik:RadAjaxPanel>
            </div>
        </form>

    Code behind:

     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
        End Sub
    
    
        Protected Sub m_oOverviewToolbar_ButtonClick(sender As Object, e As RadToolBarEventArgs) Handles m_oOverviewToolbar.ButtonClick
            Dim oBtn As RadToolBarButton = e.Item
            If (oBtn.CommandName = "Edit") Then
    
    
            ElseIf (oBtn.CommandName = "View") Then
                MsgBox("sssss")
            End If
    
        End Sub

    Result:

     

    Best regards,

    Sean

    Tuesday, April 21, 2020 5:56 AM