Home > Forum > ASP.NET > Button is not firing when validation control is set for textbox in asp.net

Button is not firing when validation control is set for textbox in asp.net

by Thamil   on Sep 23, 2014   Category: ASP.NET  |  Views: 2286    |  Points: 5   |  Gold 
  Reply
I am using different panels in c# asp.net. In each panel I have separate next button. In one panel I am validating the textbox that txtbox should validate when next button is firing but my button is not firing. If I make cause validation false then textbox is not validating..... please help me what s the problem

Question posted on behalf of sudha.


Bookmark and Share:
 
  User Reply  | Ask a question  |   Reply 
  Re :Button is not firing when validation control is set for textbox in asp.net   
by Thamil
on Sep 23 2014 1:26AM
Points : 10
Gold 
Hi Sudha,

I have specified the defaultbutton preporty in each panel and assigned button in panel level. Also included the ValidationGroup preporty in the RequiredFieldValidator and button as like below, so now when you click on next button in panel2 RequiredFieldValidator would validate the texboxes, hope this will help you.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm7.aspx.cs" Inherits="LearnDev.WebForm7" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" DefaultButton="btnSubmit">
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:TextBox ID="txtJob" runat="server"></asp:TextBox><br />
<asp:Button ID="btnSubmit" runat="server" Text="Enter" OnClick="btnSubmit_Click" />
</asp:Panel>

<asp:Panel ID="Panel2" runat="server" DefaultButton="btnNext">
<asp:TextBox ID="txtAge" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqAge" runat="server" ValidationGroup="Vgrp" ControlToValidate="txtAge"
ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtPlace" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqPlace" runat="server" ValidationGroup="Vgrp" ControlToValidate="txtPlace"
ErrorMessage="*"></asp:RequiredFieldValidator><br />
<asp:Button ID="btnNext" ValidationGroup="Vgrp" runat="server" Text="Next" OnClick="btnNext_Click" />
</asp:Panel>
</div>
</form>
</body>
</html>
  Re :Button is not firing when validation control is set for textbox in asp.net   
by sudha
on Sep 25 2014 5:55AM
Points : 10
Starter 
Thank you soo much... I dont have validation group in my code thats a prob... No its working

Recent Post

Latest Posts

1 3D model and 2D View New! Forum