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

Grid with external Edit form RadInputManager validation not failing.

6 Answers 143 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 02 Nov 2010, 08:23 PM
I have a grid that's using a separate Edit form that has a RadInputManager to validate control values (Note: The RIM and controls are part of a user control that makes up a portion of the edit form). Most of these are standard (ASP) textboxes and the RIM is properly showing the entry cues (i.e. "Please enter text here."). However, when the form is submitted, the RIM validators (?) are not firing to show the missing/incorrect fields and are also not preventing the form from being submitted (form is being posted back with bad data).

On the server side, if I check Page.IsValid, the result is true. Previously, I had a similar issue where the RIM validation was flagging the fields as bad (i.e. showing a red outline in the offending field(s)), but was still submitting the form immediately instead of forcing the user to correct the bad data.

Here's a snippet of the RadInputManager properties that are set:

<telerik:RadInputManager id="RadInputManager1" runat="server">
    <telerik:TextBoxSetting ErrorMessage="Required field." Validation-IsRequired="True"
        EmptyMessage="Please type here." Validation-ValidateOnEvent="Submit" >
        <TargetControls>
            <telerik:TargetInput ControlID="txtFirstName" Enabled="true" />
            <telerik:TargetInput ControlID="txtLastName" Enabled="true" />
            <telerik:TargetInput ControlID="txtEmail" Enabled="true" />
        </TargetControls>
        <Validation IsRequired="True" ValidationGroup="AccountValidationGroup">
        </Validation>
    </telerik:TextBoxSetting>
    <telerik:RegExpTextBoxSetting ErrorMessage="Please enter a valid email address."
        ValidationExpression="^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$" Validation-ValidateOnEvent="Submit">
        <TargetControls>
            <telerik:TargetInput ControlID="txtEmail" Enabled="true" />
        </TargetControls>
    <Validation IsRequired="True" ValidationGroup="AccountValidationGroup"></Validation>
    </telerik:RegExpTextBoxSetting>
</telerik:RadInputManager>


And here is the markup for the fields themselves:

<div style="float: left; width: 50%;">
    <table cellspacing="0" border="0" summary="Edit Table">
        <tr>
            <td align="right">
                <asp:Label ID="lblFirstName" runat="server" Text="First Name" /> 
            </td>
            <td>
                <asp:TextBox ID="txtFirstName" runat="server" AutoCompleteType="FirstName" 
                    TabIndex="3" />
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="lblLastName" runat="server" Text="Last Name" /> 
            </td>
            <td>
                <asp:TextBox ID="txtLastName" runat="server" AutoCompleteType="LastName" 
                    TabIndex="4" />
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="lblEmail" runat="server" Text="Email" /> 
            </td>
            <td>
                <telerik:RadTextBox ID="txtEmail" runat="server" AutoCompleteType="None" 
                    TabIndex="9"></telerik:RadTextBox>
            </td>
        </tr>
    </table>
</div>

Has anyone seen this issue before and/or know of a solution?

Thanks,

Jon

6 Answers, 1 is accepted

Sort by
0
Jon
Top achievements
Rank 1
answered on 03 Nov 2010, 06:23 PM

Update:

OK, so some of the issues I had were self-inflicted. I hadn't set the CausesValidation property to True for the fields I needed to validate. Doing this properly prompted for messages, but didn't solve the form submitting with invalid data.

To solve this, I ended up adding a JavaScript function to the OnClientClick property for the button on the form that submits the user's changes:

<script type="text/javascript">
    function ValidateForm()
    {
        var validators = Page_Validators;
        var validator = null;
        var result = false;
        var validatorIndex = 0;
  
        if (validators)
        {
            for (; validatorIndex < validators.length; validatorIndex++)
            {
                validator = validators[validatorIndex]
                if (validator)
                {
                    ValidatorValidate(validator)
                    result = validator.isvalid;
                }
                if (result == false)
                    break;
            }
        }
        if (result == true)
            __doPostBack("<%= btnUpdate.ClientID %>", null);
        else
            return false;
    }
</script>

And the markup for the button is as follows:

<asp:Button ID="btnUpdate" runat="server" OnClientClick="return ValidateForm(this);"
    ValidationGroup="UserValidationGroup" TabIndex="40" CausesValidation="True"
    UseSubmitBehavior="true" />

Hope this helps someone else!

Jon
0
Pavlina
Telerik team
answered on 05 Nov 2010, 04:46 PM
Hello,

Thank you for sharing your solution with the community. I am sure it would be helpful for anyone searching such functionality.

Best wishes,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andre Myburgh
Top achievements
Rank 1
answered on 05 Jan 2011, 12:06 PM
Pavlina, that is not a very nice comment to make seeing as that searching for such functionality is not exceptional but quite common.

Jon has highlighted a bug in the RadInputManager (which btw, I'm experiencing as well) and yet you waive it as something that the control should not be doing.

In my instance the postback is blocked on the first click of the button. On the second click it still submits the "unvalidated" data.

Has anyone managed to block the form from posting back garbage eventhough IsRequired is set?
0
Pavlina
Telerik team
answered on 10 Jan 2011, 04:46 PM
Hello Andre,

Could you please send us a sample where we could replicate the issue in order to debug it locally and get to the source of the issue. You could open a formal support ticket from your Telerik account and attach a ZIP file there. Thus we will be able to gather more details about your scenario and to provide you a solution.

Thank you.

Regards,
Pavlina
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
Andre Myburgh
Top achievements
Rank 1
answered on 11 Jan 2011, 08:30 AM
Sure, I will keep it in the Forum.

It is costing our company just as much submitting this issue as it is your company fixing it, might as well make it available to other Telerik users.

I have atached the Master page, the specific page that is not working and the database tables that would be needed to replicate the issue. Sorry that it is not a solution, or a working sample, as the complete project is huge and I'm sure you understand that I cannot post a fully fledged application without nondisclosure.

To simulate the issue, either add a new record to the grid or edit an exiting one. Leave both fields blank, click update/insert. You will see the required field style and no postback (the way it should be). Enter a value into the first field. Click update (it still works right). Enter the second field and clear the first. Click update. The inputmanager should have stopped the postback (because the Code field is blank), but let it slip through.

While you are at it, that bit of code in the master page around required fields/field sizes is not comprehensive, but the feature would be nice in the grid. Also note another bug that was detailed in a comment in the function AddRequiredFieldValidator.

The runtime version of the control is v2.0.50727 (2010.1.519.35). You can find the attached files in the support ticket. I see that your image validation works on this forum and thus I cannot post it here. Hope you can do the same for the validation on the InputManager :)

Take care,
Andre

Edit: I see my support contract for 2011 is not in place yet. Send me an email address and I will forward you the zip file. I don't want to spam the forum with the code.
0
Pavlina
Telerik team
answered on 14 Jan 2011, 09:49 AM
Hello Jon,

We provide support only through our support ticketing system. If you want to send us a project then open a formal support ticket or upload it in some public web site from where we can download it.

Best wishes,
Pavlina
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.
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Jon
Top achievements
Rank 1
Pavlina
Telerik team
Andre Myburgh
Top achievements
Rank 1
Share this question
or