RadButton throws error

3 posts, 1 answers
  1. Chaz
    Chaz avatar
    6 posts
    Member since:
    Jan 2013

    Posted 04 Mar 2013 Link to this post

    I'm getting this error:

    The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).



    Form this markup:

    <%@ Reference Page="~/Checking.aspx" %>
    <%@ Page Language="C#" MasterPageFile="~/OLBMaster.master" Title="Order Check Request"
        AutoEventWireup="true" CodeFile="CheckOrderCopy.aspx.cs" CodeFileBaseClass="CU.Session+Page"
        Inherits="BPOB.OrderCheckCopy" %>
     
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
    <%--<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI, Version=2012.3.1205.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" %>--%>
     
     
    <asp:Content runat="server" ID="Content0" ContentPlaceHolderID="HeadContent">
     
        <script type="text/javascript" src="js/validate.js"></script>
        <script type="text/javascript" src="js/jquery.validate.wrapper.js"></script>
        <script type="text/javascript">
             
            function ValidateOrderForm(sender, args)
            {
                $(document).ready(function ()
                {
                    $('#aspnetForm').validate({ errorClass: 'ValidateError' });
                    // validation rules
                    $('#<%=accountNumber.ClientID%>').rules('add', { required: true, messages: { required: ' Required' } });
                    $('#<%=ckNumLabel.ClientID%>').rules('add', { required: true, messages: { required: ' Required' } });
                    $('#<%=dateLabel.ClientID%>').rules('add', { required: true, messages: { required: ' Required' } });
                    $('#<%=dateLabel.ClientID%>').rules('add', { date: true, messages: { date: ' Invalid Format' } });
                    $('#<%=amountLabel.ClientID%>').rules('add', { required: true, messages: { required: ' Required' } });
                    $('#<%=amountLabel.ClientID%>').rules('add', { number: true, messages: { number: ' Invalid Input' } });
     
                    if ($('#aspnetForm').valid()) {
                        args.set_cancel(false); //allow pressing to continue
                    } else {
                        args.set_cancel(true); //abort processing
                    }
                });
            }
     
            function ValidateFaxOrder(sender, args)
            {
     
                $(document).ready(function ()
                {
                    $('#aspnetForm').validate({ errorClass: 'ValidateError' });
                    //validation
                    $('#<%=t_Phone_First3.ClientID%>').rules('add', { required: true, messages: { required: ' Required' } });
                    $('#<%=t_Phone_First3.ClientID%>').rules('add', { number: true, messages: { number: ' Invalid Input' } });
                    $('#<%=t_Phone_First3.ClientID%>').rules('add', { minlength: 3, messages: { minlength: ' Too few' } });
                    $('#<%=t_Phone_Second3.ClientID%>').rules('add', { required: true, messages: { required: ' Required' } });
                    $('#<%=t_Phone_Second3.ClientID%>').rules('add', { number: true, messages: { number: ' Invalid Input' } });
                    $('#<%=t_Phone_Second3.ClientID%>').rules('add', { minlength: 3, messages: { minlength: ' Too few' } });
                    $('#<%=t_Phone_Last4.ClientID%>').rules('add', { required: true, messages: { required: ' Required' } });
                    $('#<%=t_Phone_Last4.ClientID%>').rules('add', { number: true, messages: { number: ' Invalid Input' } });
                    $('#<%=t_Phone_Last4.ClientID%>').rules('add', { minlength: 4, messages: { minlength: ' Too few' } });
                    if ($('#aspnetForm').valid()) {
                        args.set_cancel(false); //allow pressing to continue
                    } else {
                        args.set_cancel(true); //abort processing
                    }
                });
     
     
            }
             
     
        </script>
    </asp:Content>
     
         
     
    <asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentBody">
         
        <asp:label id="statusLabel" runat="server" ForeColor="Red" Font-Names="Arial" Font-Bold="True">Status</asp:label>
     
        <asp:panel id="mailCheck" Runat="server">
            <table cellSpacing="0" cellPadding="4" width="95%" align="center" bgColor="white">
                <tr>
                    <td><b>This check is no longer viewable online, however you can request a copy be
                            mailed to you.</b>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table cellSpacing="5" cellPadding="3" width="500" align="center" border="0">
                            <tr class="AlternateRow2">
                                <td><b>Name:</b></td>
                                <td>
                                    <asp:Label id="nameLabel" runat="server"></asp:Label></td>
                            </tr>
                            <tr class="AlternateRow1">
                                <td><b>Email:</b></td>
                                <td>
                                    <asp:Label id="emailLabel" runat="server"></asp:Label></td>
                            </tr>
                            <tr class="AlternateRow2">
                                <td><b>Account:</b></td>
                                <td><asp:DropdownList id="accountNumber" runat="server"></asp:DropdownList>
                                </td>
                            </tr>
                            <tr class="AlternateRow1">
                                <td><b>Check #:</b></td>
                                <td>
                                    <asp:TextBox id="ckNumLabel" runat="server"></asp:TextBox></td>
                            </tr>
                            <tr class="AlternateRow2">
                                <td><b>Date Cleared:</b></td>
                                <td>
                                    <asp:TextBox id="dateLabel" runat="server"></asp:TextBox></td>
                            </tr>
                            <tr class="AlternateRow1">
                                <td><b>Amount:</b></td>
                                <td>
                                    <asp:TextBox id="amountLabel" runat="server"></asp:TextBox></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td><b>Please note that a service fee of $3.00 per check will apply to your request.
                            We will send a copy of the check (both the front & back side) to the mailing
                            address we have on file for you via the U.S. Postal Service. If the check
                            cleared within the last year we will put it in the mail within 3-5 business
                            days. If the check cleared over a year ago we will put it in the mail within 10
                            business days. Need it faster?
                            <asp:LinkButton id="faxLink" OnClick="faxLink_Click" runat="server">Click Here</asp:LinkButton>.</b><br>
                        <br>
                    </td>
                </tr>
                <tr>
                    <TD align="center">
     
                        <telerik:RadButton ID="OrderButton" runat="server" Text="RadButton"></telerik:RadButton>
     
                        <%--<asp:ImageButton id="OrderButton" OnClick="OrderButton_Click" runat="server" ImageUrl="images/buttons/Button_OrderCheckCopy.gif" ToolTip="Order Check Copy"></asp:ImageButton>--%></td>
                </tr>
            </table>
        </asp:panel>
     
        <asp:panel id="faxIt" Runat="server">
            <table>
                <tr>
                    <td class="TextGreenBold">We can fax the copy to you, but PLEASE NOTE:</td>
                </tr>
                <tr>
                    <td>
                        <ul>
                            <li>
                                <b>We cannot guarantee that the copy will be faxed at a specific time, so if you
                                    are uncomfortable with your personal checking account information sitting on a
                                    fax machine for a time before you pick it up, you should not choose this
                                    option.</b><br>
                                <br>
                            <li>
                                <b>The information on the back of the check can often be difficult to read on a
                                    faxed copy. So if you choose this option we will also mail a copy to you.</b>
                            </li>
                        </ul>
                        <table class="AccountTable" align="center">
                            <tr>
                                <td class="TextBlueBold">Fax Number:</td>
                                <td>
                                    <table cellSpacing="0" cellPadding="0">
                                        <tr>
                                            <td>(
                                                <asp:TextBox id="t_Phone_First3" Runat="server" MaxLength="3" Width="30px"></asp:TextBox>)</td>
                                            <td>
                                                <asp:TextBox id="t_Phone_Second3" Runat="server" MaxLength="3" Width="30px"></asp:TextBox>-</td>
                                            <td>
                                                <asp:TextBox id="t_Phone_Last4" Runat="server" MaxLength="4" Width="40px"></asp:TextBox></td>
                                        </tr>
                                    </table>
                                </td>
                                <td>
                                    <asp:ImageButton id="faxSubmitButton" OnClick="faxSubmitButton_Click" runat="server" ImageUrl="images/buttons/Button_Submit_Blue.gif" ToolTip="Submit"></asp:ImageButton></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </asp:panel>
     
    </asp:Content>

    And it's driving me crazy - can't find a solution.  I've searched against the error message and can't find a solution that has worked thus far.

    What I've been trying to work with is RadScriptBlock and RadCodeBlock.


    I'm at my wit's end :-(

    Suggestions?
  2. Answer
    Danail Vasilev
    Admin
    Danail Vasilev avatar
    1490 posts

    Posted 07 Mar 2013 Link to this post

    Hello Chaz,

    You have placed server-side blocks within your markup and therefore you are having this error message. In order to prevent this message from appearing you can simply but the JavaScript that contains the code blocks inside a RadCodeBlock. For example:

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
       <script type="text/javascript">
            function ValidateOrderForm(sender, args) {
                $(document).ready(function () {
             ...
                });
            }
     
            function ValidateFaxOrder(sender, args) {
     
                $(document).ready(function () {
              ...
                });
            }        
        </script>
    </telerik:RadCodeBlock>

    More information about the RadCodeBlock is available in this help article.

    Regards,
    Danail Vasilev
    the Telerik team
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chaz
    Chaz avatar
    6 posts
    Member since:
    Jan 2013

    Posted 13 Mar 2013 Link to this post

    That worked!

    I had, previously tried would with the RadCodeBlock control with no luck.

    I employed it exactly as illustrated and page now works fine - it at least renders now ;-)

    Thanks.
Back to Top