RegularExpressionValidator 不允许我进入下一页

发布于 2024-07-14 15:25:29 字数 5910 浏览 10 评论 0原文

我有两个数据列表。 其工作原理类似于菜单,您可以单击链接来填充其他数据列表。 我还添加了下一个和上一个链接按钮,以便在不同的“页面”之间移动,这样您就不必使用菜单数据列表进行更改。

现在,在后面的代码中,根据我从数据库中获取的值,我添加了一个正则表达式验证器。

这非常有效,直到我想使用下一个按钮(或上一个按钮)。 即使与 RegularExpressionValidator 相比,检查的所有控件都是有效的,我也永远无法加载新值。 下一个和上一个按钮会触发数据列表选定的索引更改事件,然后我检查单击的是否是上一个或下一个按钮。

但上一个和下一个按钮已经麻木了。 他们甚至不触发该事件。 就像点击背景一样。 什么都没发生。

我已经检查了 PageIs.Valid,这是真的。

有谁知道可能是什么导致了这种行为?

提前致谢!

下面的一些文本是瑞典语的,但这对代码来说应该不重要。

rev_checkfieldvalue.ControlToValidate = "tb_detailValue";
switch (iDataTypeId)
{
    case 2:
        rev_checkfieldvalue.ValidationExpression = @"^\d*[0-9 ]+$";
        rev_checkfieldvalue.Text = "Fältet får endast innehålla siffror och mellanslag.";
        break;
    case 3:
        break;
    case 4:
        break;
    case 5:
        rev_checkfieldvalue.ValidationExpression = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
        rev_checkfieldvalue.Text = "Fältet får endast innehålla en e-postadress.";
        break;

}
e.Item.Controls.AddAt(32, rev_checkfieldvalue);

<asp:DataList ID="dl_componentInfo" DataKeyField="ComponentId" runat="server" OnItemDataBound="dl_componentInfo_OnItemDataBound" OnItemCommand="dl_componentInfo_OnItemCommand">
    <ItemTemplate>
        <table>
            <tr>
                <td colspan="2"><asp:Label ID="lb_componentName" SkinID="lblHeader" runat="server" Text='<%# Eval("ComponentName") %>' /></td>
            </tr>
            <tr>
                <td colspan="2">Fält markerade med * är obligatoriska</td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td>
                    <asp:DataList ID="dl_details" OnItemDataBound="dl_details_OnItemDataBound" runat="server">
                        <ItemTemplate>
                            <table>
                                <tr>
                                    <td colspan="2">
                                        <asp:Label ID="lbl_detailName" Text='<%# Eval("DetailName") %>' runat="server"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:Label ID="lbl_custDetName" runat="server" />
                                    </td>
                                    <td align="left">
                                        <%--Always hidden values--%>
                                        <asp:Label ID="lbl_detailTypeId" Visible="false" Text='<%# Eval("DetailTypeId") %>' runat="server" />
                                        <asp:Label ID="lbl_detailId" Visible="false" Text='<%# Eval("DetailId") %>' runat="server" />
                                        <asp:Label ID="lbl_dataTypeId" Visible="false" Text='<%# Eval("DataTypeId") %>' runat="server" />
                                        <asp:Label ID="lbl_customerEventValueId" Visible="false" Text='<%# Eval("CustomerEventValueId") %>' runat="server" />
                                        <asp:Label ID="lbl_reqFld" Visible="false" Text='<%# Eval("ReqFld") %>' runat="server" />

                                        <%--Sometimes visible values--%>
                                        <asp:Label ID="lbt_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
                                        <asp:Label ID="lbtb_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
                                        <asp:Label ID="lbth_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
                                        <asp:Label ID="lbc_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
                                        <asp:DropDownList ID="dd_detailValue" Visible="false" runat="server"></asp:DropDownList>
                                        <%--Om det ska gå att markera/avmarkera alla så använd AJAX--%>
                                        <asp:CheckBoxList ID="cbl_detailValue" RepeatDirection="Horizontal" RepeatLayout="flow" Visible="false" runat="server" />
                                        <asp:CheckBox ID="cb_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
                                        <asp:TextBox ID="tb_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
                                        <asp:TextBox ID="ta_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server"></asp:TextBox>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:DataList>
                </td>
            </tr>
        </table>
    </ItemTemplate>
    <FooterTemplate>
        <table width="600">
            <tr>
                <td>
                    <asp:LinkButton id="lb_previous" Text="Föregående" CommandName="Previous" runat="server"/>
                </td>
                <td>
                    <asp:LinkButton id="lb_next" Text="Nästa" CommandName="Next" runat="server"/>
                </td>
            </tr>
        </table>
    </FooterTemplate>
</asp:DataList>

I have two datalists. One works like a menu where you click on a link to fill the othe datalist.
I also have added a next and previous linkbutton to move between the different "pages" so that you do not have to change using the menu datalist.

Now in code behind depending on which values I get from the database I add a RegularExpressionValidator.

This works great until I want to use the next button (or previous for that matter). Even if all the controls that are checked are valid when compared with the RegularExpressionValidator I never get to load the new values.
The next and previous buttons fires the datalist selected index change event and then I check if it is the previous or next button that was clicked.

But the previous and next buttons are numb. They don't even fire the event.
It is like clicking on the background. Nothing happens.

I have chcked the PageIs.Valid and it is true.

Does anyone have a clue what it could be that is causing this behavior?

Thanks in advance!

Some of the texts down there is in Swedish but it shouldn't matter for the code.

rev_checkfieldvalue.ControlToValidate = "tb_detailValue";
switch (iDataTypeId)
{
    case 2:
        rev_checkfieldvalue.ValidationExpression = @"^\d*[0-9 ]+$";
        rev_checkfieldvalue.Text = "Fältet får endast innehålla siffror och mellanslag.";
        break;
    case 3:
        break;
    case 4:
        break;
    case 5:
        rev_checkfieldvalue.ValidationExpression = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
        rev_checkfieldvalue.Text = "Fältet får endast innehålla en e-postadress.";
        break;

}
e.Item.Controls.AddAt(32, rev_checkfieldvalue);

<asp:DataList ID="dl_componentInfo" DataKeyField="ComponentId" runat="server" OnItemDataBound="dl_componentInfo_OnItemDataBound" OnItemCommand="dl_componentInfo_OnItemCommand">
    <ItemTemplate>
        <table>
            <tr>
                <td colspan="2"><asp:Label ID="lb_componentName" SkinID="lblHeader" runat="server" Text='<%# Eval("ComponentName") %>' /></td>
            </tr>
            <tr>
                <td colspan="2">Fält markerade med * är obligatoriska</td>
            </tr>
            <tr>
                <td> </td>
                <td>
                    <asp:DataList ID="dl_details" OnItemDataBound="dl_details_OnItemDataBound" runat="server">
                        <ItemTemplate>
                            <table>
                                <tr>
                                    <td colspan="2">
                                        <asp:Label ID="lbl_detailName" Text='<%# Eval("DetailName") %>' runat="server"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:Label ID="lbl_custDetName" runat="server" />
                                    </td>
                                    <td align="left">
                                        <%--Always hidden values--%>
                                        <asp:Label ID="lbl_detailTypeId" Visible="false" Text='<%# Eval("DetailTypeId") %>' runat="server" />
                                        <asp:Label ID="lbl_detailId" Visible="false" Text='<%# Eval("DetailId") %>' runat="server" />
                                        <asp:Label ID="lbl_dataTypeId" Visible="false" Text='<%# Eval("DataTypeId") %>' runat="server" />
                                        <asp:Label ID="lbl_customerEventValueId" Visible="false" Text='<%# Eval("CustomerEventValueId") %>' runat="server" />
                                        <asp:Label ID="lbl_reqFld" Visible="false" Text='<%# Eval("ReqFld") %>' runat="server" />

                                        <%--Sometimes visible values--%>
                                        <asp:Label ID="lbt_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
                                        <asp:Label ID="lbtb_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
                                        <asp:Label ID="lbth_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
                                        <asp:Label ID="lbc_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
                                        <asp:DropDownList ID="dd_detailValue" Visible="false" runat="server"></asp:DropDownList>
                                        <%--Om det ska gå att markera/avmarkera alla så använd AJAX--%>
                                        <asp:CheckBoxList ID="cbl_detailValue" RepeatDirection="Horizontal" RepeatLayout="flow" Visible="false" runat="server" />
                                        <asp:CheckBox ID="cb_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
                                        <asp:TextBox ID="tb_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
                                        <asp:TextBox ID="ta_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server"></asp:TextBox>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:DataList>
                </td>
            </tr>
        </table>
    </ItemTemplate>
    <FooterTemplate>
        <table width="600">
            <tr>
                <td>
                    <asp:LinkButton id="lb_previous" Text="Föregående" CommandName="Previous" runat="server"/>
                </td>
                <td>
                    <asp:LinkButton id="lb_next" Text="Nästa" CommandName="Next" runat="server"/>
                </td>
            </tr>
        </table>
    </FooterTemplate>
</asp:DataList>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绝不放开 2024-07-21 15:25:29

我以为我解决了问题,但它只是停止检查。

I thought I solved the issue but it just stopped checking.

就像说晚安 2024-07-21 15:25:29

因此,对于第二种情况,您接受任何非空的数字和空格字符串。

这是你的意图吗?

So for case two you accept any non-empty string of digits and spaces.

Is that your intent?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文