locked
Problem with Validator RRS feed

  • Question

  • User-1634117515 posted

    Hello 

    I'm using a RangeValidator but I have a problem with one button I want when the user does not want to continue can return to the main Page but if the Validator is working or showing the error message I can´t return to Main Page

    here is the code 

     <div class="form-group">
                            <label>Días Solicitados: </label>                        
                             <asp:TextBox ID="txtDias" runat="server" placeholder="1" TextMode="Number"  CssClass="form-control" Width="100%"/>
                            <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Número de dias invalidos" ControlToValidate="txtDias" MinimumValue="1" Display="Dynamic" MaximumValue="50" ForeColor="Red" Text="Debe solicitar minimo un día de vacaciones"></asp:RangeValidator>
                        </div>
     <div class="form-row">
                            <div class="form-group col-md-6 ">
                            <asp:Button ID="btnEnviar" runat="server" Text="Generar Solicitud" CssClass="btn btn-info form-control"  Width="100%" OnClick="btnEnviar_Click"/>
                            </div>
                            <div class="form-group col-md-6">
                            <asp:Button ID="btnLimpiar" runat="server" Text="Cancelar" CssClass="btn btn-danger form-control" Width="100%" OnClick="btnLimpiar_Click" />
                        </div>
                    </div>        

    and here is the code on for the button 

     protected void btnLimpiar_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Response.Redirect("Default.aspx");
            }
            else
            {
                Response.Redirect("Default.aspx");
            }
        }

    I hope someone can help me, Thanks.

    Friday, June 7, 2019 2:21 PM

Answers

All replies