English 中文(简体)
ASP. 表格中的数据验证摘要
原标题:ASP.NET validation summary inside formview doesn t work

我在表格表中有一个验证摘要,而有效的人似乎并没有触发验证摘要。

我已尝试过:

  • Enable the ViewState on everything.
  • Set the ClientID to static.
  • Set the ValidationGroup to the same group on both all validators and the summary.
  • Used Google to search for a solution.

没有人对如何处理这一问题有任何想法?

法典:概览声明

<asp:FormView ID="FormViewPerson" runat="server" DataSourceID="ObjectDataSourcePerson"
    DefaultMode="Edit" OnItemUpdating="FormViewPerson_ItemUpdating" OnItemCommand="FormViewPerson_ItemCommand"
    OnItemUpdated="FormViewPerson_ItemUpdated" Width="100%">

与有效方的任何文本箱:

<td>  <asp:TextBox ID="NumberTextBox" runat="server" Text= <%# Bind("Number") %>  
                        TabIndex="10" CausesValidation="True" ClientIDMode="Static" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorNumber" runat="server" ControlToValidate="NumberTextBox"
                        ErrorMessage="Number is Required" ForeColor="Red" 
                        ValidationGroup="EditPerson">*</asp:RequiredFieldValidator>
                </td>

提交:

<asp:ValidationSummary ID="ValidationSummaryPerson" runat="server" 
            ForeColor="Red" ClientIDMode="Static" CssClass="validation" 
            ShowMessageBox="True" ValidationGroup="EditPerson" ViewStateMode="Enabled"
            />
        <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
            Text="Save" ValidationGroup="EditPerson" CssClass="ButtonStyle" TabIndex="90" />
        &nbsp;<asp:Button ID="EditCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
            Text="Cancel" CssClass="ButtonStyle" TabIndex="100" 
            ValidationGroup="EditPerson" />
最佳回答

希望《纽 约》的<编码>CausesValidation被定为真实情况。

问题回答

我确定这个问题。 如果其他人遇到这一问题,则试图:

  • Ensure there is only one (1) validation group on the entire form.
  • Set "causesvalidation" to "true" on the submitbutton.
  • Check, double check and triple check the spelling of your validationgroup property on all relevant controls.
  • Be on the lookout for javascript errors in your client-side scripts. They can cause havoc.




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签