2016-12-23 2 views
0

Итак, у меня есть простая таблица и одна RequiredFieldValidator. Простейший код всех и до сих пор, сервер работает даже тогда, когда он не проходит проверкуПроверка всегда Runninng - Even When fail

Validator:

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="FnameReg" runat="server" ErrorMessage="הכנס שם פרטי"></asp:RequiredFieldValidator> 

стол (его 2 таблицы внутри одной таблицы)

<table border="0" style="opacity:0.9"> 
    <tr> 
     <td colspan="3" style="background-color:#BCA795;font-size:xx-large;color:white;text-align:center"> 
      הרשמה</td> 

    </tr> 
    <tr> 
     <td style="vertical-align:top"> 
      <%[email protected]@@@--%> 
      <table border="0" style="background-color:white;border-collapse:collapse;text-align:right;width:250px"> 
       <tr> 
        <td dir="rtl"> 

         &nbsp;&nbsp;&nbsp; 
          <asp:RadioButtonList ID="BuildStyleReg" runat="server"> 
            <asp:ListItem>באדי-בילדינג</asp:ListItem> 
            <asp:ListItem>פאוור-ליפטינג</asp:ListItem> 
            <asp:ListItem>סטריט-וורקאאוט</asp:ListItem> 
            <asp:ListItem>לא מתאמן</asp:ListItem> 
          </asp:RadioButtonList> 

     &nbsp;&nbsp;</td> 
        <td style="padding: 10px; background-color: #BCA795; color: white"> 

         סוג אימון</td> 
       </tr> 
       <tr> 
        <td dir="rtl" style="text-align:right"> 


        <asp:RadioButtonList ID="TargetReg" runat="server"> 
        <asp:ListItem Text="מסה"></asp:ListItem> 
        <asp:ListItem Text="חיטוב"></asp:ListItem> 
        <asp:ListItem Text="ניטרלי"></asp:ListItem> 

        </asp:RadioButtonList> 

        </td> 
        <td style="padding: 10px; background-color: #BCA795; color: white"> 

         &nbsp;&nbsp; 

         תקופת מטרה</td> 
       </tr> 
       <tr> 

        <td dir="rtl"> 

     <asp:CheckBoxList ID="sadas" runat="server"> 
      <asp:ListItem Text="טבעי"></asp:ListItem> 
      <asp:ListItem Text="תוספי תזונה"></asp:ListItem> 
      <asp:ListItem Text="טבעונית"></asp:ListItem> 
     </asp:CheckBoxList> 

        </td> 
        <td style="padding: 10px; background-color: #BCA795; color: white"> 
         תזונה</td> 
       </tr> 
       <tr> 
        <td class="auto-style7" colspan="2" style="background-color: #957860" align="center"> 

     <input id="SubmitReg" type="submit" value="שלח" style="color: #957860; background-color: #FFFFFF; font-size: xx-large;" />      
        </td> 
       </tr> 
       </table> 

     </td> 
     <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
     </td> 
     <td style="vertical-align:top"> 

      <%[email protected]@@@@--%> 

      <table border="0" style="background-color:white;border-collapse:collapse;text-align:right;width:250px"> 
          <tr> 
           <td class="auto-style6"> 

            &nbsp; 
      <asp:TextBox ID="FnameReg" runat="server"></asp:TextBox> 
          </td> 
           <td style="background-color: #BCA795; color: white; padding-right: 10px; padding-left: 10px;" class="auto-style6"> 

            שם פרטי</td> 
          </tr> 
          <tr> 
           <td> 

            &nbsp;&nbsp;<asp:TextBox ID="LnameReg" runat="server"></asp:TextBox> 

           </td> 
           <td style="background-color: #BCA795; color: white; padding-right: 10px; padding-left: 10px;"> 

            שם משפחה</td> 
          </tr> 
          <tr> 
           <td> 

            &nbsp;&nbsp;<asp:TextBox ID="EmailReg" runat="server"></asp:TextBox> 

           </td> 
           <td style="background-color: #BCA795; color: white; padding-right: 10px; padding-left: 10px;"> 

            אימייל</td> 
          </tr> 
          <tr> 
           <td> 

      <asp:TextBox ID="PassReg" runat="server" TextMode="Password"></asp:TextBox> 

           </td> 
           <td style="background-color: #BCA795; color: white; padding-right: 10px; padding-left: 10px;"> 

            סיסמא</td> 
          </tr> 
          <tr> 
           <td class="auto-style3"> 

      <asp:TextBox ID="RepassReg" runat="server" TextMode="Password"></asp:TextBox> 

           </td> 
           <td class="auto-style3" style="background-color: #BCA795; color: white; padding-right: 10px; padding-left: 10px;"> 


            אימות סיסמא</td> 
          </tr> 
          <tr> 
           <td> 

      <asp:TextBox ID="CellPhoneReg" runat="server" TextMode="Password"></asp:TextBox> 

           </td> 
           <td style="background-color: #BCA795; color: white; padding-right: 10px; padding-left: 10px;"> 

            פלאפון</td> 
          </tr> 
          <tr> 
           <td> 

      <asp:TextBox ID="DateReg" runat="server" TextMode="Date"></asp:TextBox> 

           </td> 
           <td style="background-color: #BCA795; color: white; padding-right: 10px; padding-left: 10px;"> 

            תאריך לידה</td> 
          </tr> 
          <tr> 
           <td> 

      <asp:DropDownList ID="DropDownList1" runat="server"> 
       <asp:ListItem Value="-1">בחר עיר</asp:ListItem> 
       <asp:ListItem Value="1">תל אביב</asp:ListItem> 
       <asp:ListItem Value="2">יפו</asp:ListItem> 
       <asp:ListItem Value="3">ירושלים</asp:ListItem> 
       <asp:ListItem Value="4">מודיעין</asp:ListItem> 
       <asp:ListItem Value="5">אילת</asp:ListItem> 
       <asp:ListItem Value="6">מעגן מיכאל</asp:ListItem> 
       <asp:ListItem Value="7">חיפה</asp:ListItem> 
       <asp:ListItem Value="8">שוהם</asp:ListItem> 
       <asp:ListItem Value="9">לפיד</asp:ListItem> 
       <asp:ListItem Value="10">רמת גן</asp:ListItem> 
      </asp:DropDownList> 

           </td> 
           <td style="background-color: #BCA795; color: white; padding-right: 10px; padding-left: 10px;"> 

            עיר</td> 
          </tr> 
          <tr> 
           <td> 

      <asp:TextBox ID="AdressReg" runat="server"></asp:TextBox> 

           </td> 
           <td style="background-color: #BCA795; color: white; padding-right: 10px; padding-left: 10px;"> 

            כתובת</td> 
          </tr> 
          <tr> 
           <td> 


      <asp:TextBox ID="CommentReg" runat="server" TextMode="MultiLine" Height="50px" Width="150px"></asp:TextBox> 


           </td> 
           <td style="background-color: #BCA795; color: white; padding-right: 10px; padding-left: 10px;"> 

            הערות</td> 
          </tr> 
          <tr> 
           <td> 

      <asp:FileUpload ID="ImageReg" runat="server" Width="25%" /> 

           </td> 
           <td style="background-color: #BCA795; color: white; padding-right: 10px; padding-left: 10px;"> 

            תמונה</td> 
          </tr> 
         </table> 
     </td> 

     <td> 
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

     </td> 
      <td style="padding:7px;margin:7px;color:red"> 
      <asp:ValidationSummary ID="ValidationSummary1" runat="server" BackColor="White" DisplayMode="List"></asp:ValidationSummary> 
     </td> 
    </tr> 
    <tr> 
     <td colspan="3"> 
      &nbsp;</td> 
    </tr> 
</table> 

почему он всегда загружает сервер?

ответ

0

Вам необходимо присвоить значение ValidationGroup к вашему валидатору и TextBox контроля, как это:

<asp:TextBox ID="FnameReg" runat="server" ValidationGroup="CheckOrSomething"></asp:TextBox> 

Значение ValidationGroup должно быть одинаковым в обеих контролирующих.

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="FnameReg" runat="server" ErrorMessage="הכנס שם פרטי" ValidationGroup="CheckOrSomething"></asp:RequiredFieldValidator> 

И вы можете назначить CausesValidation=True к Button.

+0

решил: я должен был поставить Asp: кнопка –

+0

Вы можете использовать любой ** Postback проверочные **. Вам просто нужно включить в него 'ValidationGroup'. – Null

0

решаемые

Я должен был использовать жерех: кнопку вместо ввода отправить

Смежные вопросы