Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Validation

Validation

Scheduled Pinned Locked Moved Web Development
helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tsepoz
    wrote on last edited by
    #1

    I'm trying to validate on client side with requiredfields but my big problem is if the page with requiredfields was activated when i want to go to another page am unable to click buttons cause nothing was putted on those required fields.So how do i control my requiredfields to only work on a certain click not on page activation. Tsepo "mafunwa" Barnabas DUT

    B 1 Reply Last reply
    0
    • T Tsepoz

      I'm trying to validate on client side with requiredfields but my big problem is if the page with requiredfields was activated when i want to go to another page am unable to click buttons cause nothing was putted on those required fields.So how do i control my requiredfields to only work on a certain click not on page activation. Tsepo "mafunwa" Barnabas DUT

      B Offline
      B Offline
      Brent Lamborn
      wrote on last edited by
      #2

      Set the Page_ValidationActive javascript variable to false in the button's OnClick event. This works: In your ASPX (had to remove beginning angle brackets to get it to render on CP :) ):

      <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

      Untitled Page
      
      
      
      
      
      asp:RequiredFieldValidator runat="server" id="rfv" ControlToValidate="txt" ErrorMessage="Error">
      asp:TextBox runat="server" ID="txt">
      asp:Button runat="server" ID="btn" Text="Go" OnClick="btn\_Click" />
      
      
      
      
      function TurnOffVal()
          {
              Page\_ValidationActive = false;
          }
      

      And in the code behind:

      using System;
      using System.Data;
      using System.Configuration;
      using System.Web;
      using System.Web.Security;
      using System.Web.UI;
      using System.Web.UI.WebControls;
      using System.Web.UI.WebControls.WebParts;
      using System.Web.UI.HtmlControls;

      public partial class _Default : System.Web.UI.Page
      {
      protected void Page_Load(object sender, EventArgs e)
      {
      btn.Attributes.Add("onclick", "TurnOffVal();");
      }
      protected void btn_Click(object sender, EventArgs e)
      {
      Response.Redirect("http://www.codeproject.com");
      }
      }


      "Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups