Working with a RadWindow gives error

12 posts, 0 answers
  1. Kris
    Kris avatar
    17 posts
    Member since:
    Dec 2006

    Posted 20 Dec 2010 Link to this post

    Hello,

    I want to change the default button with a RadButton.  This button opens a RadWindow.

    My previous code was:
    <asp:ImageButton ID="btnFunctie" runat="server" onclientclick="ShowDialog();return false;" CssClass="imgbtn" Height="16px" Width="16px"/>

    New code:
    <telerik:RadButton ID="btnFunctie" runat="server" onclientclicking="ShowDialog();return false;"></telerik:RadButton>

    The new code gives a Javascript error and its definetly with the  -- onclientclicking="ShowDialog();return false;" --

    Can you help me out with this?  I have no knowledge with Java.

    Kind Regards,
    Kris

  2. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 20 Dec 2010 Link to this post

    Hello Kris,

    Your RadButton should look like the following:
    <telerik:RadButton ID="btnFunctie" runat="server" onclientclicking="ShowDialog" AutoPostBack="false"></telerik:RadButton>

    The properties that are used to specify the RadButton's (or any RadControl's) client-side events, like OnClientCliking, OnClientClicked and etc., expect the name of the JavaScript function to be passed. So, whenever you handle client-side events of the RadControls for ASP.NET AJAX, pass only the name of the function.

    Best wishes,
    Pero
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kris
    Kris avatar
    17 posts
    Member since:
    Dec 2006

    Posted 20 Dec 2010 Link to this post

    I get other error's:

    window.radopen=

    function(a,c){var b=GetRadWindowManager();

     

    return

     

    b.open(a,c); <- on this line

    and on this line:

     

     

    var oWnd = window.radopen("fundialog.aspx?ITD=" + document.getElementById('ctl00_Main_txtITDAC').value + "&FUN=" + document.getElementById('ctl00_Main_txtFunctie').value + "&EC=" + document.getElementById('ctl00_Main_txtEC').value, "DialogWindow");

    I don't get anymore the javascript error but no window after pressing the button...

     

  5. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 21 Dec 2010 Link to this post

    Hi Kris,

    Did you set RadButton's AutoPostBack property to false? You could also try the OnClientClicked property, instead of the OnClientClicking, because the "clicked" event is fired at a later stage.

    Kind regards,
    Pero
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  6. Kris
    Kris avatar
    17 posts
    Member since:
    Dec 2006

    Posted 21 Dec 2010 Link to this post

    Yes, the AutoPostback is set to false.
    I get the follwing error: Microsoft JScript runtime error: 'undefined' is null or not an object

    I changed it now to onclientclicked:

     

    <telerik:RadButton ID="btnFunctie" runat="server" onclientclicked="ShowDialog()" AutoPostBack="False"></telerik:RadButton>

     

    I get the same error on the line:  return b.open(a,c); in Telerik.Web.UI.W... -> Microsoft JScript runtime error: 'undefined' is null or not an object

    Other suggestions?

  7. Kris
    Kris avatar
    17 posts
    Member since:
    Dec 2006

    Posted 21 Dec 2010 Link to this post

    Great now it works?! I just removed the 2 () after ShowDialog...  How stupid can it be...  Now I just tested it once, I hope of course that this is the solution.

    Thanks a lot for the help otherwise I didn't saw it!!!
  8. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 21 Dec 2010 Link to this post

    Hello Kris,

    Yes that's the solution.

    As I said in one of my previous the properties used to specify the client-side events of the RadButton (or any other RadControl for ASP.NET AJAX) expect only the name of the JavaScript function that handles the event, without parenthesis and parameters.

    Best wishes,
    Pero
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  9. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 31 Dec 2010 Link to this post

    Hello Pero,
    Then in that scenario, when I try to show and edit dialog when I press an edit buton in my grid?
    How am I expected to access to the current row data to get access to the current item I want to edit?

    For exemple, to use the following function you can spot in many of your samples:
    function ShowEditForm(id, rowIndex) {
        var grid = $find("<%= RadGrid1.ClientID %>");
     
        var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
        grid.get_masterTableView().selectItem(rowControl, true);
     
        window.radopen("Session.aspx?SessionID=" + id, "SessionDialog");
        return false;
    }

    If I don't pass any parameter to my function, how can I make all this work?
    Thank you for your help.
    John.

  10. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 03 Jan 2011 Link to this post

    Hello John,

    In that case there are a couple of ways to call your JavaScript function and pass parameters to it. In the following forum post from my colleague Georgi, you will find attached a sample project that demonstrates how to pass parameters to JavaScript function from the code-behind.

    The first approach is to assign an anonymous function to the OnClientClicked property, and call the other JS function in the anonymous function, i.e.:
    RadButton1.OnClientClicked = "function(button,args){ ShowDialog('id','Name') }";

    The other approach is to set the CommandArgument property of the RadButton, and then use the button.get_commandArgument() to get the parameters on the client.

    Please test the sample project in the forum provided above, it uses both approaches, plus demonstrates another one.

    Greetings,
    Pero
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  11. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 03 Jan 2011 Link to this post

    Hello Pero,
    Excellent stuff. Works like a charm. I'd go for the get_commandArgument style.
    Thank you for your help,
    Happy new year,
    John.
  12. Gaurav
    Gaurav avatar
    6 posts
    Member since:
    Feb 2013

    Posted 03 Jun 2013 Link to this post

    Hey Friends please help me with an error that I am facing working with Radwindow. The scenario is:

    I have an aspx page in which all the content is inside an asp:UpdatePanel.  Now on clicking of a telerik button on the page, postback occurs and the server processing starts. Now based on the results of the processing I am adding a script.

     ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "DisplayMissingPages();", true);

    The function DisplayMissingPages is defined as:

            function DisplayMissingPages() {         
                radopen("MissingPublicationCodesPagesReport.aspx?sitemap=29", "RadWindow3");            
                return false;
            }

    The window is defined as :

                    <Telerik:RadWindowManager ID="RadWindowManager3" runat="server" EnableShadow="true" >
                        <Windows>
                            <Telerik:RadWindow ID="RadWindow3" runat="server" ReloadOnShow="true"                             
                                ShowContentDuringLoad="true" Width="900px" Height="900px" Title="Telerik RadWindow"
                                Behaviors="Default" ClientIDMode="Static">
                            </Telerik:RadWindow>
                        </Windows>
                    </Telerik:RadWindowManager>

    What I basically wish to do is to open a radwindow after the server finish processing and the control returns back to the client. Based on my debugging I have verified that the script is getting added from server side and DisplayMissingPages does executes but still radwindow does not open. Instead I get a javascript error on

    window.radopen=

    function(a,c){var b=GetRadWindowManager();

     return 

    b.open(a,c); <- on this line 


    The error is b is not defined. 

    Could anyone give me a solution about how I can display a radwindow after the server finishes processing and the control returns back to the client. 

    Waiting eagerly for an answer.

    Thanks and Regards,
    Gaurav

  13. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1494 posts

    Posted 06 Jun 2013 Link to this post

    Hi Gaurav,

    On AJAX update the content inside the update panel is disposed and that is so for the window object which is placed there. The error you are receiving is due to the lack of the window object. In order to ensure that all script are loaded, you can use the sys.application.add_load() event. For example:
    C#
    protected void OnClick1(object sender, EventArgs e)
    {
        string showWndScript = "function f(){DisplayMissingPages(); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);";
        ScriptManager.RegisterStartupScript(this, this.GetType(), "showWnd", showWndScript, true); 
    }
    ASPX:
    <asp:UpdatePanel ID="Updatepanel1" runat="server">
        <ContentTemplate>
            <telerik:RadWindowManager ID="RadWindowManager3" runat="server" EnableShadow="true">
                <Windows>
                    <telerik:RadWindow ID="RadWindow3" runat="server" ReloadOnShow="true" ShowContentDuringLoad="true"
                        Width="900px" Height="900px" Title="Telerik RadWindow" Behaviors="Default" ClientIDMode="Static">
                    </telerik:RadWindow>
                </Windows>
            </telerik:RadWindowManager>
            <telerik:RadButton ID="RadButton1" runat="server" Text="Click" OnClick="OnClick1" />
        </ContentTemplate>
    </asp:UpdatePanel>
    JavaScript:
    <script type="text/javascript">
        function DisplayMissingPages() {
            radopen("http://www.bing.com", "RadWindow3");
            return false;
        }
    </script>
    You can also find useful the Executing JavaScript function from server-side code help article.


    Regards,
    Danail Vasilev
    Telerik
    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 the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017