Enabled property of RadTextBox changes on validation.

2 posts, 0 answers
  1. Alessio
    Alessio avatar
    14 posts
    Member since:
    May 2009

    Posted 18 Feb 2010 Link to this post

    Hi, there's a problem with radtextbox.
    I've 3 radtextblock with enabled property set false at design time in my .aspx page, a raddatepicker with a customvalidator and a button to start the validation.
    When validation occours (on click button) the enabled property of the 3 textbox turn to true. Here an example:
    <%@ Page Title="" Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="WebApplication1.Default2" %> 
     
    <html xmlns="http://www.w3.org/1999/xhtml"
    <head id="Head1" runat="server"
        <title>Titolo</title> 
        <telerik:RadStyleSheetManager ID="RadStyleSheetManagerMain" runat="server" /> 
    </head> 
    <body id="bodyBackgroundImage" runat="server"
        <center> 
            <form id="form1" runat="server"
            <telerik:RadScriptManager ID="RadScriptManagerMain" runat="server"
                <Scripts> 
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> 
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> 
                </Scripts> 
            </telerik:RadScriptManager> 
            <telerik:RadAjaxManager ID="RadAjaxManagerMain" runat="server" /> 
            <table class="bodytable" width="950" cellpadding="0" cellspacing="0" border="0"
                <!-- HEADER --> 
                <tr> 
                    <td> 
                        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="headertable"
                            <tr> 
                                <td> 
                                    <!--height="88"--> 
                                    <table width="100%" class="headertable" border="0" cellpadding="0" cellspacing="0"
                                        <tr> 
                                            <td align="left"
                                            </td> 
                                             
                                        </tr> 
                                        <tr> 
                                             
                                        </tr> 
                                    </table> 
                                </td> 
                            </tr> 
                            <tr> 
                                <td> 
                                        <table id="TableMenu" width="100%" cellspacing="0" cellpadding="0" border="0" class="maintitletable" 
                                            runat="server"
                                            <tr style="height: 33px;"
                                                <td width="20%"
                                                </td> 
                                                <td width="10%"
                                                </td> 
                                                <td align="right"
                                                    <!-- HOME --> 
                                                    <id="A1" href="~/Default.aspx" runat="server">Home</a> 
                                                </td> 
                                            </tr> 
                                            <tr> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                            </tr> 
                                        </table> 
                                </td> 
                            </tr> 
                        </table> 
                    </td> 
                </tr> 
                <!-- BODY --> 
                <tr> 
                    <td class="bodytable"
                        <table border="0" cellpadding="0" cellspacing="0"
                            <tr> 
                                <td id="leftColumn"
                                    <div class="rightmain"
                                    </div> 
                                    <!-- Menu condiviso--> 
                                     
                                </td> 
                                <td> 
                                    &nbsp; 
                                </td> 
                                <td id="centercolumn"
                                    <div class="centermain"
    <table> 
        <tr> 
            <td> 
                Field 1 
            </td> 
            <td colspan="2"
                <telerik:RadTextBox ID="RadTextBoxId1" runat="server" EmptyMessage="Text 1" 
                    Width="280px" Enabled="False" > 
                </telerik:RadTextBox> 
                 
            </td> 
        </tr> 
        <tr> 
            <td> 
                Field 2 
            </td> 
            <td colspan="2"
                <telerik:RadTextBox ID="RadTextBoxId2" runat="server" EmptyMessage="Text 2" 
                    Width="280px" Enabled="False"
                </telerik:RadTextBox> 
            </td> 
        </tr> 
        <tr> 
            <td  > 
                Field 3 
            </td> 
            <td colspan="2"
                <telerik:RadTextBox ID="RadTextBoxId3" runat="server" EmptyMessage="Text 3" 
                    Width="280px" Enabled="False"
                </telerik:RadTextBox> 
            </td> 
        </tr> 
        <tr> 
            <td style="width:280px;" > 
                Date (*) 
            </td> 
            <td colspan="2"
                <telerik:RadDatePicker ID="RadDatePickerDataInserimento" runat="server" Calendar-CultureInfo="Italian (Italy)" 
                        Calendar-RangeMaxDate="06/06/2079 00:00:00" Calendar-RangeMinDate="01/01/1900 00:00:00" 
                        MaxDate="06/06/2079 00:00:00" MinDate="01/01/1900 00:00:00" Width="280px" > 
                        <DateInput DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy" MaxDate="06/06/2079 00:00:00" MinDate="01/01/1900 00:00:00" /> 
                    </telerik:RadDatePicker> 
                <asp:CustomValidator ID="CustomValidatorDataInserimento" runat="server" 
                        ValidationGroup="ButtonConferma" ErrorMessage="Error" 
                        OnServerValidate="CustomValidatorDatInserimento_ServerValidate"
                    </asp:CustomValidator> 
            </td> 
        </tr> 
        
           <tr> 
            <td   /> 
            <td colspan="2"
                <asp:Button ID="ButtonConferma" runat="server" Text="Click" OnClick="ButtonConferma_Click" CausesValidation="true" ValidationGroup="ButtonConferma" /> 
            </td> 
        </tr> 
    </table> 
                                    </div> 
                                </td> 
                            </tr> 
                        </table> 
                    </td> 
                </tr> 
                <!-- footer --> 
                <tr> 
                    <td> 
                        <div> 
                            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="footertable"
                                <tr> 
                                    <td class="footertable"
                                        &nbsp 
                                    </td> 
                                </tr> 
                                <tr> 
                                    <td> 
                                        <hr /> 
                                    </td> 
                                </tr> 
                                <tr> 
                                    <td class="footertable"
                                        <strong>Footer</strong> 
                                    </td> 
                                </tr> 
                            </table> 
                        </div> 
                    </td> 
                </tr> 
            </table> 
            </form> 
        </center> 
    </body> 
    </html> 
     
    using System; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
     
    namespace WebApplication1 
        public partial class Default2 : Page 
        { 
            protected void Page_Load(object sender, EventArgs e) 
            { 
            } 
     
            protected void ButtonConferma_Click(object sender, EventArgs e) 
            { 
            } 
     
            protected void CustomValidatorDatInserimento_ServerValidate(object source, ServerValidateEventArgs args) 
            { 
                args.IsValid = false
            } 
        } 

    Any ideas?
  2. Alessio
    Alessio avatar
    14 posts
    Member since:
    May 2009

    Posted 18 Feb 2010 Link to this post

    Ok, after many days i've found solution.
    Simply use OnPreRender event:
    protected void RadTextBoxIdImpresa_OnPreRender(object sender, EventArgs e) 
            { 
                ((RadTextBox)sender).Enabled = false
            } 

    Sorry ;)
Back to Top