15,886,830 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Predator008 (Top 10 by date)
Predator008
14-Sep-12 16:02pm
View
Could you plz explain that using a concrete example? thanks
Predator008
14-Sep-12 15:34pm
View
I m not using Forms at all I wanna go for Session or queryString to do this. Is it appropriate? or am I going to have a hard time going this way?
I m using a Master Page, I m thinking of using QueryString and check it in this master page and see whether the user is logged in or not? the querystring will be encrypted and contain the username, something like this
Predator008
12-Sep-12 10:14am
View
indeed it is client side validation, thanks anyway NothingToLoose and _Amy
Predator008
12-Sep-12 8:56am
View
I got it work, i still have just some minor problems in the execution of the ifs. here are the ifs i ve put in my logic:
protected void SearchButton_Click(object sender, EventArgs e)
{
BLL.EmpLNameValidate bl = new BLL.EmpLNameValidate();
if (!bl.RequiredLname(LNameText.Text))
{
Label1.Text = "Last Name is required!";
lblLnameValid.Visible = true;
EmpDataView.Visible = false;
}
else if(!bl.LenghtValidate(LNameText.Text))
{
Label1.Text = "Please enter at least 2 characters!";
lblLnameValid.Visible = true;
EmpDataView.Visible = false;
}
else if (!CharactersValidate(LNameText.Text))
{
Label1.Text = "Only alphabets are allowed!";
lblLnameValid.Visible = true;
EmpDataView.Visible = false;
}
else if (FNameText.Text.Length > 0 & !bl.LenghtValidate(FNameText.Text))
{
Label2.Text = "Please enter at least 2 characters!";
lblFnameValid.Visible = true;
EmpDataView.Visible = false;
}
else if (FNameText.Text.Length > 0 & !CharactersValidate(FNameText.Text))
{
Label2.Text = "Only alphabets are allowed!";
lblFnameValid.Visible = true;
EmpDataView.Visible = false;
}
else
{
lblLnameValid.Visible = false;
lblFnameValid.Visible = false;
Label1.Text = null;
Label2.Text = null;
BindData();
if (EmpDataView.Rows.Count == 0)
{
NewUserLabel.Visible = true;
NewUserButton.Visible = true;
}
else
{
EmpDataView.Visible = true;
NewUserLabel.Visible = false;
NewUserButton.Visible = false;
}
}
}
where my BLL file (Class) looks like this:
namespace Phonebook.BLL
{
// TODO Validate that the user have entred characters for Last Name field
public class EmpLNameValidate
{
// to validate last name is required
public bool RequiredLname(string txt)
{
if (!string.IsNullOrEmpty(txt))
{
return true;
}
else
{
return false;
}
}
// to validate 2 characters lenght
public bool LenghtValidate(string txt)
{
if (txt.Length < 2)
{
return false;
}
else
{
return true;
}
}
}
}
i run it it's working but still some minor "inpurities" in the ifs.
Predator008
11-Sep-12 11:54am
View
I've done like you said before but it didn't work, maybe I am missing something or I misplaced the logic behind this.
thnks anyway Wes
Predator008
11-Sep-12 11:32am
View
:D yeah I can. I've wrote something like that to check characters entred
public bool validateCharacters(string input, string msg) {
const string regExpr = @"^[a-zA-Z]+$"; //regular expression for valid string
// match input with regular expression
System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(input, regExpr);
if (m.Success) { msg = null;
return true; } else {
msg= "characters"; return false; }
}and like this to check requiered field:
public bool RequiredLname(string txt, string msg) {
if (string.IsNullOrEmpty(txt)) {
msg = "Last name required"; return false;
} else { msg = null;
return true; } }
But I would like to do is use the IsValid in my main page to check the validation using my customvalidators.
Predator008
11-Sep-12 11:20am
View
could you plz translate that to a concrete example? like how I should declare my function in BLL file? what parameters to pass?
Predator008
11-Sep-12 11:16am
View
to be clear here is what I want:
I have a search button and a GridViewcontrol, whaen a user clicks the button the validation sould validate that the last name has been filled in, and if so it should contain at least 2 characters, then if the user chooses to include first name, he should also enter 2 characters, but it's not a required field:
protected void SearchButton_Click(object sender, EventArgs e) {
//if validation passesBindData();
if (EmpDataView.Rows.Count == 0) {
NewUserLabel.Visible = true;
NewUserButton.Visible = true; }
else {
EmpDataView.Visible = true;
NewUserLabel.Visible = false;
NewUserButton.Visible = false; }
// else show error messages
Predator008
11-Sep-12 11:09am
View
suppose I create a function called LNameValidate() in BLL file, now I want to call it form my main page in whcich my customvalidator resides, as you said I should go to the events and on Server Validate cell put the name of that function (BLL.LNameValidate())?
Predator008
11-Sep-12 11:01am
View
Hey, the problem is that those functions now exist in my main page code behind, I want to place them in a file named BLL in which there is a Class file. I want to put them in this Class file and call them from there. The logic how to do this is not clear to me, how to handel the ServerValidate and TextChanged events from another location.
Show More