其他UpdatePanel的HTML5必填字段使用ASP.NET中的第一个UpdatePanel进行验证



我有两个UpdatePanel。每个UpdatePanel都有ASP.NET控件,这些控件具有必需的HTML5属性。当我单击UpdatePanel1上的提交按钮时,它还会验证UpdatePanel2中的控件,并且在我不处理UpdatePanel中所需的ASP.NET控件之前不会继续操作。

有人能帮我一下吗。

下面是我所做的代码。

<div class="tab_container"> 
                            <div id="tab1" class="tab_content"> 
                                 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                    <ContentTemplate>
                                        <table class="tbl">
                                            <tr>
                                                <td>Id:</td>
                                                <td><asp:TextBox ID="txtId" runat="server"></asp:TextBox></td>
                                                <td>PIN:</td>
                                                <td><asp:TextBox ID="txtPIN" runat="server" autofocus required></asp:TextBox></td>
                                                <td rowspan="2" colspan="2">
                                                    <div>
                                                        <asp:Image ID="img" CssClass="employeepic" runat="server" />
                                                        <asp:FileUpload ID="fu" runat="server" Style="position: absolute; top: 65px; right: 50px; width: 80px;" required />
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Tazkira / Passport: No</td>
                                                <td><asp:TextBox ID="txtTazPas" runat="server" required></asp:TextBox></td>
                                                <td>TIN:</td>
                                                <td><asp:TextBox ID="txtTIN" runat="server" required></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td>Last Name:</td>
                                                <td><asp:TextBox ID="txtLastName" runat="server"></asp:TextBox></td>
                                                <td>First Name:</td>
                                                <td><asp:TextBox ID="txtFirstName" runat="server" required></asp:TextBox></td>
                                                <td>Father Name:</td>
                                                <td><asp:TextBox ID="txtFatherName" runat="server" required></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td>Gender:</td>
                                                <td>
                                                    <asp:DropDownList ID="ddlGender" runat="server">
                                                        <asp:ListItem Value="Male">Male</asp:ListItem>
                                                        <asp:ListItem Value="Female">Female</asp:ListItem>
                                                    </asp:DropDownList>
                                                </td>
                                                <td>Nationality:</td>
                                                <td>
                                                    <asp:DropDownList ID="ddlNationality" runat="server" DataSourceID="CountriesEntityDataSource" DataTextField="Nationality" DataValueField="Nationality">
                                                    </asp:DropDownList>
                                                    <asp:EntityDataSource ID="CountriesEntityDataSource" runat="server" ConnectionString="name=ChemonicsDBEntities" DefaultContainerName="ChemonicsDBEntities" EnableFlattening="False" EntitySetName="Countries" Select="it.[Id], it.[Country1], it.[Nationality]" OrderBy="it.[Id] asc" Where="it.[DeletedBy] = 0">
                                                    </asp:EntityDataSource>
                                                </td>
                                                <td>Date of Birth:</td>
                                                <td><asp:TextBox ID="txtDOB" runat="server" data-date-format="mm.dd.yyyy" datepicker data-week-start="6" required></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td>Present Address:</td>
                                                <td colspan="5"><asp:TextBox ID="txtPreDetailedAddress" Width="97.4%" runat="server"></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td>District:</td>
                                                <td><asp:TextBox ID="txtPreDistrict" runat="server"></asp:TextBox></td>
                                                <td>Province:</td>
                                                <td><asp:TextBox ID="txtPreProvince" runat="server"></asp:TextBox></td>
                                                <td>Country:</td>
                                                <td>
                                                    <asp:DropDownList ID="ddlPreCountry" runat="server" DataSourceID="CountriesEntityDataSource" DataTextField="Country1" DataValueField="Country1">
                                                    </asp:DropDownList>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Permanent Address:</td>
                                                <td colspan="5"><asp:TextBox ID="txtPerDetailedAddress" Width="97.4%" runat="server"></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td>District:</td>
                                                <td><asp:TextBox ID="txtPerDistrict" runat="server"></asp:TextBox></td>
                                                <td>Province:</td>
                                                <td><asp:TextBox ID="txtPerProvince" runat="server"></asp:TextBox></td>
                                                <td>Country:</td>
                                                <td>
                                                    <asp:DropDownList ID="ddlPerCountry" runat="server" DataSourceID="CountriesEntityDataSource" DataTextField="Country1" DataValueField="Country1">
                                                    </asp:DropDownList>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Official Email:</td>
                                                <td><asp:TextBox ID="txtOfficialEmail" runat="server" TextMode="Email"></asp:TextBox></td>
                                                <td>Personal Email:</td>
                                                <td><asp:TextBox ID="txtPersonalEmail" runat="server" TextMode="Email"></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td>Official Phone:</td>
                                                <td><asp:TextBox ID="txtOfficialPhone" runat="server" TextMode="Number"></asp:TextBox></td>
                                                <td>Personal Phone:</td>
                                                <td><asp:TextBox ID="txtPersonalPhone" runat="server" TextMode="Number" required></asp:TextBox></td>
                                                <td>Skype Id:</td>
                                                <td><asp:TextBox ID="txtSkypeId" runat="server"></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">Has USA Visa<asp:CheckBox ID="chkUSAVisa" runat="server" /></td>
                                                <td colspan="2">Life insurance send to head office<asp:CheckBox ID="chkLifeInsurance" runat="server" /></td>
                                                <td colspan="2">Can take report from all projects<asp:CheckBox ID="chkReportingFromAll" runat="server" /></td>
                                            </tr>
                                            <tr>
                                                <td></td>
                                                <td colspan="5"><asp:Button ID="btnSave" runat="server" Text="Save" CssClass="buttonleft" OnClick="btnSave_Click"></asp:Button><asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="buttonright" OnClick="btnCancel_Click"></asp:Button></td>
                                            </tr>
                                           </table>                                                        
                                    </ContentTemplate>
                                        <Triggers>
                                            <asp:PostBackTrigger ControlID="btnSave" />
                                    </Triggers>
                                </asp:UpdatePanel>
                            </div>
                            <div id="tab2" class="tab_content"> 
                                <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                                    <ContentTemplate>
                                        <table class="tbl">
                                            <tr>
                                                <td>Id:</td>
                                                <td><asp:TextBox ID="txtOfficialId" runat="server"></asp:TextBox></td>
                                                <td>Position:</td>
                                                <td>
                                                    <asp:DropDownList ID="ddlOfficialPosition" runat="server" DataSourceID="PositionsEntityDataSource" DataTextField="PositionType" DataValueField="PositionType"></asp:DropDownList>
                                                    <asp:EntityDataSource ID="PositionsEntityDataSource" runat="server" ConnectionString="name=ChemonicsDBEntities" DefaultContainerName="ChemonicsDBEntities" EnableFlattening="False" EntitySetName="Positions" Select="it.[PositionType]" Where="it.[DeletedBy] = 0">
                                                    </asp:EntityDataSource>
                                                </td>
                                                <td>Position Details:</td>
                                                <td><asp:TextBox ID="txtOfficialPositionDetails" runat="server"></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td>Project:</td>
                                                <td>
                                                    <asp:DropDownList ID="ddlOfficialProject" AutoPostBack="true" runat="server" DataSourceID="ProjectsEntityDataSource" DataTextField="Name" DataValueField="Id" OnSelectedIndexChanged="ddlOfficialProject_SelectedIndexChanged"></asp:DropDownList>
                                                    <asp:EntityDataSource ID="ProjectsEntityDataSource" runat="server" ConnectionString="name=ChemonicsDBEntities" DefaultContainerName="ChemonicsDBEntities" EnableFlattening="False" EntitySetName="Projects" Select="it.[Id], it.[Name]" Where="it.[DeletedBy] = 0">
                                                    </asp:EntityDataSource>
                                                </td>
                                                <td>Department:</td>
                                                <td>
                                                    <asp:DropDownList ID="ddlOfficialDepartment" runat="server"></asp:DropDownList>
                                                    <asp:EntityDataSource ID="DepartmentsEntityDataSource" runat="server" ConnectionString="name=ChemonicsDBEntities" DefaultContainerName="ChemonicsDBEntities" EnableFlattening="False" EntitySetName="Departments" Select="it.[Id], it.[Name], it.[ProjectId]" Where="it.[DeletedBy] = 0 and it.[ProjectId] = @ProId" EntityTypeFilter="">
                                                    </asp:EntityDataSource>
                                                </td>
                                                <td>Duty Station:</td>
                                                <td>
                                                    <asp:TextBox ID="txtOfficialDutyStation" runat="server"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Contract Type:</td>
                                                <td>
                                                    <asp:DropDownList ID="ddlOfficialContractType" runat="server">
                                                    </asp:DropDownList>
                                                </td>
                                                <td>Employment Type:</td>
                                                <td>
                                                    <asp:DropDownList ID="ddlOfficialEmploymentType" runat="server">
                                                    </asp:DropDownList>
                                                </td>
                                                <td>&nbsp;</td>
                                                <td>&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td>Grade:</td>
                                                <td>
                                                    <asp:DropDownList ID="ddlOfficialGrade" runat="server">
                                                    </asp:DropDownList>
                                                </td>
                                                <td>Step:</td>
                                                <td>
                                                    <asp:DropDownList ID="ddlOfficialStep" runat="server">
                                                    </asp:DropDownList>
                                                </td>
                                                <td>&nbsp;</td>
                                                <td>&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td>Start Date:</td>
                                                <td><asp:TextBox ID="txtOfficialStartDate" runat="server" data-date-format="mm.dd.yyyy" datepicker data-week-start="6" required></asp:TextBox></td>
                                                <td>End Date:</td>
                                                <td><asp:TextBox ID="txtOfficialEndDate" runat="server" data-date-format="mm.dd.yyyy" datepicker data-week-start="6" required></asp:TextBox></td>
                                                <td>&nbsp;</td>
                                                <td>&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td>Active:</td>
                                                <td></td>
                                                <td>Seperation Type:</td>
                                                <td></td>
                                                <td>Seperation Date:</td>
                                                <td><asp:TextBox ID="txtOfficialSeperationDate" runat="server" data-date-format="mm.dd.yyyy" datepicker data-week-start="6"></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td>Notes:</td>
                                                <td colspan="5"><asp:TextBox ID="txtOfficialNotes" runat="server" TextMode="MultiLine"></asp:TextBox></td>
                                            </tr>
                                        </table>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </div>

最新更新