I have a simple RadWindow popup from a button using ContentTemplate - with a Cancel and an Update Button
the Cancel button closes the form fine with the following script
the Update needs to do something, then close the form
only it doesn't even close the form
help!
thanks
oh and clicking the Update also throws a JavaScript error in some Telerik Web script library
<telerik:RadWindow ID="rwLumpSum" Modal="true" Top="0" Left="0" VisibleOnPageLoad="false" runat="server" > <ContentTemplate> <asp:UpdatePanel ID="cpLumpSum" UpdateMode="Conditional" runat="server"> <ContentTemplate> <table> <tr> <td>Lump Sum</td> <td> <telerik:RadNumericTextBox ID="rntbLumpSum" MinValue="1" MaxValue="999.99" runat="server"> <NumberFormat DecimalDigits="2" /> </telerik:RadNumericTextBox> </td> </tr> <tr> <td> <telerik:RadButton id="rbCancel" Text="Cancel" OnClientClicked="rbCancelClicked" AutoPostBack="false" UseSubmitBehavior="false" runat="server" /> </td> <td> <telerik:RadButton id="rbUpdate" Text="Update" runat="server" /> </td> </tr> </table> </ContentTemplate> </asp:UpdatePanel> </ContentTemplate></telerik:RadWindow>the Cancel button closes the form fine with the following script
function rbCancelClicked(button) { var rwLumpSum = $find("<%=rwLumpSum.ClientID%>"); rwLumpSum.Close();}the Update needs to do something, then close the form
only it doesn't even close the form
Protected Sub rbUpdate_Click(sender As Object, e As EventArgs) Handles rbUpdate.Click Dim ws As CommonFunctions Dim sb As StringBuilder = Nothing do something here
sb = New StringBuilder("<SCRIPT language='javascript'>") sb.Append("var rwLumpSum = $find(") sb.Append(Chr(34)) sb.Append("<%=rwLumpSum.ClientID%>") sb.Append(Chr(34)) sb.Append(");rwLumpSum.Close();") sb.Append("</SCRIPT>") ws = New CommonFunctions() ScriptManager.RegisterStartupScript(Me, Me.GetType(), "CloseWindow", sb.ToString, False)End Subhelp!
thanks
oh and clicking the Update also throws a JavaScript error in some Telerik Web script library
6 Answers, 1 is accepted
0
Hi Marianne,
The server code blocks you have seen used to get a reference to our controls are code executed on the server during the render phase of the page and while they do resolve to a string they are not the string that you need to reference our controls. They can only be used in the markup, in the code-behind you need to concatenate the strings as shown in this sticky thread that also shows how to work with the RadWindow from the code-behind: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx.
The exact exception you get is a generic server error and does not come from our controls and thus you need to debug your page to see where it originates and how to fix it. The error you have received is simply the way MS AJAX traps server errors.
Here is the code that I tried on my end and works fine with the RadWindow:
Note that I lowercased the first letter of the RadWindow methods as this is the way they should be used. I also changed the script tag to a proper one.
Regards,
Marin Bratanov
Telerik
The server code blocks you have seen used to get a reference to our controls are code executed on the server during the render phase of the page and while they do resolve to a string they are not the string that you need to reference our controls. They can only be used in the markup, in the code-behind you need to concatenate the strings as shown in this sticky thread that also shows how to work with the RadWindow from the code-behind: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx.
The exact exception you get is a generic server error and does not come from our controls and thus you need to debug your page to see where it originates and how to fix it. The error you have received is simply the way MS AJAX traps server errors.
Here is the code that I tried on my end and works fine with the RadWindow:
<script type="text/javascript"> function rbCancelClicked(button) { var rwLumpSum = $find("<%=rwLumpSum.ClientID%>"); rwLumpSum.close(); } function openRw() { var rwLumpSum = $find("<%=rwLumpSum.ClientID%>"); rwLumpSum.show(); }</script><asp:Button ID="Button1" Text="open the RadWindow" OnClientClick="openRw(); return false;" runat="server" /><telerik:RadWindow ID="rwLumpSum" Modal="true" Top="0" Left="0" VisibleOnPageLoad="false" runat="server"> <ContentTemplate> <asp:UpdatePanel ID="cpLumpSum" UpdateMode="Conditional" runat="server"> <ContentTemplate> <table> <tr> <td> Lump Sum </td> <td> <telerik:RadNumericTextBox ID="rntbLumpSum" MinValue="1" MaxValue="999.99" runat="server"> <NumberFormat DecimalDigits="2" /> </telerik:RadNumericTextBox> </td> </tr> <tr> <td> <telerik:RadButton ID="rbCancel" Text="Cancel" OnClientClicked="rbCancelClicked" AutoPostBack="false" UseSubmitBehavior="false" runat="server" /> </td> <td> <telerik:RadButton ID="rbUpdate" Text="Update" runat="server" /> </td> </tr> </table> </ContentTemplate> </asp:UpdatePanel> </ContentTemplate></telerik:RadWindow>Protected Sub rbUpdate_Click(sender As Object, e As EventArgs) Handles rbUpdate.Click 'Dim ws As CommonFunctions Dim sb As StringBuilder = Nothing 'do something here sb = New StringBuilder("<script tyoe='text/javascript'>") sb.Append("var rwLumpSum = $find(") sb.Append(Chr(34)) sb.Append(rwLumpSum.ClientID) sb.Append(Chr(34)) sb.Append(");rwLumpSum.close();") sb.Append("</script>") 'ws = New CommonFunctions() ScriptManager.RegisterStartupScript(Me, Me.GetType(), "CloseWindow", sb.ToString, False)End SubNote that I lowercased the first letter of the RadWindow methods as this is the way they should be used. I also changed the script tag to a proper one.
Regards,
Marin Bratanov
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 their blog feed now.
0
Elliott
Top achievements
Rank 2
answered on 28 May 2013, 01:05 PM
thank you so much - I'll make your changes and see if that removes the error
I noticed you use an ASP:Button and not a RadButton - is there a reason?
I noticed you use an ASP:Button and not a RadButton - is there a reason?
0
No, there is no particular reason, you can replace it with a RadButton. Here is how to Migrate OnClientClick handlers from ASP button to Telerik’s ASP.NET AJAX Button. I hope that you will also be able to debug and resolve the case that cause s the server error. Perhaps you will find it easier if you remove the update panel to avoid using partial postbacks, it makes debugging a bit easier.
0
Elliott
Top achievements
Rank 2
answered on 28 May 2013, 07:38 PM
the server error was caused by triggering a function of selected from a grid
I got the RadWindow to do what I wanted it to do but - all the other buttons on the grid are disabled!
I got the RadWindow to do what I wanted it to do but - all the other buttons on the grid are disabled!
0
Elliott
Top achievements
Rank 2
answered on 28 May 2013, 08:01 PM
I found that if I removed the required field validator if worked - is this a um Telerik bug?
this one works
this one disables all the other buttons on the page
this one works
<div><telerik:RadWindow ID="rwLumpSum" Modal="true" Top="0" Left="0" VisibleOnPageLoad="false" runat="server" > <ContentTemplate> <asp:UpdatePanel ID="cpLumpSum" UpdateMode="Conditional" runat="server"> <ContentTemplate> <table> <tr> <td>Lump Sum</td> <td> <telerik:RadNumericTextBox ID="rntbLumpSum" MinValue="0" MaxValue="999.99" runat="server"> <NumberFormat DecimalDigits="2" /> </telerik:RadNumericTextBox> </td> </tr> <tr> <td> <telerik:RadButton id="rbCancel" Text="Cancel" AutoPostBack="false" CausesValidation="false" runat="server" /> </td> <td> <telerik:RadButton id="rbUpdate" Text="Update" runat="server" /> </td> </tr> </table> </ContentTemplate> </asp:UpdatePanel> </ContentTemplate></telerik:RadWindow></div><div> <telerik:RadWindow ID="rwLumpSum" Modal="true" Top="0" Left="0" VisibleOnPageLoad="false" runat="server" > <ContentTemplate> <asp:UpdatePanel ID="cpLumpSum" UpdateMode="Conditional" runat="server"> <ContentTemplate> <table> <tr> <td>Lump Sum</td> <td> <telerik:RadNumericTextBox ID="rntbLumpSum" MinValue="0" MaxValue="999.99" runat="server"> <NumberFormat DecimalDigits="2" /> </telerik:RadNumericTextBox> <asp:RequiredFieldValidator ID="rfvLumpSum" ControlToValidate="rntbLumpSum" ErrorMessage="*" runat="server" /> </td> </tr> <tr> <td> <telerik:RadButton id="rbCancel" Text="Cancel" AutoPostBack="false" UseSubmitBehavior="false" CausesValidation="false" runat="server" /> </td> <td> <telerik:RadButton id="rbUpdate" Text="Update" runat="server" /> </td> </tr> </table> </ContentTemplate> </asp:UpdatePanel> </ContentTemplate> </telerik:RadWindow></div>0
Elliott
Top achievements
Rank 2
answered on 28 May 2013, 08:09 PM
a big duh - a RequiredFieldValidator is just that - and since all the other buttons are submit buttons they trigger the validator