This is a migrated thread and some comments may be shown as answers.

Working with a RadWindow gives error

11 Answers 271 Views
Button
This is a migrated thread and some comments may be shown as answers.
Kris
Top achievements
Rank 2
Kris asked on 20 Dec 2010, 03:49 PM
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

11 Answers, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 20 Dec 2010, 04:23 PM
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.
0
Kris
Top achievements
Rank 2
answered on 20 Dec 2010, 06:24 PM
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...

 

0
Pero
Telerik team
answered on 21 Dec 2010, 02:56 PM
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.
0
Kris
Top achievements
Rank 2
answered on 21 Dec 2010, 04:22 PM
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?

0
Kris
Top achievements
Rank 2
answered on 21 Dec 2010, 04:27 PM
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!!!
0
Pero
Telerik team
answered on 21 Dec 2010, 04:51 PM
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.
0
Jonx
Top achievements
Rank 2
answered on 31 Dec 2010, 04:03 PM
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.

0
Pero
Telerik team
answered on 03 Jan 2011, 10:49 AM
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.
0
Jonx
Top achievements
Rank 2
answered on 03 Jan 2011, 11:14 AM
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.
0
Gaurav
Top achievements
Rank 1
answered on 03 Jun 2013, 10:28 AM
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

0
Danail Vasilev
Telerik team
answered on 06 Jun 2013, 08:48 AM
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.
Tags
Button
Asked by
Kris
Top achievements
Rank 2
Answers by
Pero
Telerik team
Kris
Top achievements
Rank 2
Jonx
Top achievements
Rank 2
Gaurav
Top achievements
Rank 1
Danail Vasilev
Telerik team
Share this question
or