Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input parameter 'controlId' cannot be an empty string when using validator inside formview

I have got a FormView where I have several fields. Those fields should be validated by asp.net validators, like this:

<asp:FormView ID="OrderDetails" runat="server" DataKeyNames="ID" DataSourceID="DS_Order" DefaultMode="Edit" AutoGenerateRows="false" ClientIDMode="Static" RenderOuterTable="false">
    <EditItemTemplate>
        <asp:TextBox ID="EinkaufsauftragsNr" runat="server" ClientIDMode="Static" Text='<%# Bind("EinkaufsauftragsNr") %>'/>
        <asp:CompareValidator runat="server" Operator="DataTypeCheck" Type="Integer" ValidationGroup="EditValidation" Display="Dynamic"
                                    ControlToValidate="EinkaufsauftragsNr" ErrorMessage="Nur Ganzzahlen erlaubt." CssClass="validator" />
        .....
    </EditItemTemplate>
</FormView>

But when I execute this, I get: "Input parameter 'controlId' cannot be an empty string." When I remove the validator, the error-msg disappears as well.

After searching for this problem on the net, I thought the problem was that the control cannot be found inside the formview, so I put the clientidmode="static" there -> but that didn't solve my problem. Do you have any other suggestions on how I could solve this one?

like image 512
r3try Avatar asked Nov 28 '12 14:11

r3try


1 Answers

You did not assign id to CompareValidator Control, You have to assign ID to asp:CompareValidator

Change

<asp:CompareValidator runat="server" Operator="DataTypeCheck"
    Type="Integer" ValidationGroup="EditValidation" Display="Dynamic"
    ControlToValidate="EinkaufsauftragsNr" ErrorMessage="Nur Ganzzahlen erlaubt."
    CssClass="validator" />

To

<asp:CompareValidator ID="SomeID" runat="server" Operator="DataTypeCheck"
    Type="Integer" ValidationGroup="EditValidation" Display="Dynamic"
    ControlToValidate="EinkaufsauftragsNr" ErrorMessage="Nur Ganzzahlen erlaubt."
    CssClass="validator" />
like image 72
Adil Avatar answered Nov 25 '22 02:11

Adil