dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online Membersashwini gawade
Amruta
Alwyn Duraisingh
Shine S
Chandra
Devaraj T N
pragna
Ravi JV
Pawan Awasthi
Ram
Padma
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Forums » .NET » ASP.NET »

Required Field validator


Posted Date: 07 Jul 2012      Posted By:: Naseer     Member Level: Bronze    Member Rank: 2055     Points: 2   Responses: 4



i need to get the cursor at particular field(textbox) where the required field validator is fired(how to focus on the textbox),there are many required fields are there in my form.



Responses

#679269    Author: Ultimaterengan        Member Level: Gold      Member Rank: 9     Date: 07/Jul/2012   Rating: 2 out of 52 out of 5     Points: 4

Dear Friend,
The RequiredFieldValidator control is used to make an input control a required field.If user does not give any value in textbox or any other input control,error message will display.Take the below example for RequiredFieldValidator.

Set SetFocusOnError="true" to set focus to control.


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

<!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 id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Username <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" SetFocusOnError="true" runat="server"
ControlToValidate="TextBox1" ErrorMessage="User Name cannot be blank"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="click me" />
</div>
</form>
</body>
</html>






Thanks & Regards
G.Renganathan
Nothing is mine ,Everything is yours!!!


http://renganathan1984.blogspot.com/



 
#679274    Author: Naseer      Member Level: Bronze      Member Rank: 2055     Date: 07/Jul/2012   Rating: 2 out of 52 out of 5     Points: 0

Thank Very much Renganathan.

Thanks&Regards,
Naseer.



 
#679275    Author: Naseer      Member Level: Bronze      Member Rank: 2055     Date: 07/Jul/2012   Rating: 2 out of 52 out of 5     Points: 1

sry i didn't find Rate Answer,5/5 for u man thank u.





 
#679354    Author: Paritosh Mohapatra      Member Level: Diamond      Member Rank: 6     Date: 08/Jul/2012   Rating: 2 out of 52 out of 5     Points: 3

You can set the SetFocusOnError property of the RequiredFieldValidator control to true.

Please check the following code:


<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox1" SetFocusOnError="true"></asp:RequiredFieldValidator>



Thanks & Regards
Paritosh Mohapatra
Microsoft MVP (ASP.Net/IIS)
DotNetSpider MVM



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Label is clearing inside the gridview
Previous : update panel in the page then also if change tab index.whole page is postback.partial bac
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.