473,809 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

User account already exists using Customvalidator

I've suprisingly not been able to find examples on this. I'm creating
a user account setup page, and the validators work fine on all the
other fields. But now I'm creating a customvalidator (for the first
time) and it is not doing anything. The page needs to see if a
username already exists. Am I doing this right?
<asp:textbox TabIndex="1" ID="tLogin" MaxLength="40" runat="server" />
<asp:customvali dator id="Customvalid ator1" runat="server"
EnableClientScr ipt="False" Font-Bold="True" ErrorMessage="U sername
already exists." ControlToValida te="tLogin"
OnServerValidat e="CheckUser" Display="Dynami c"/>

void CheckUser(objec t source,
System.Web.UI.W ebControls.Serv erValidateEvent Args args)
{
TextBox b;
b = fLogin.FindCont rol("tLogin") as TextBox;
String lg = b.Text;
String strConn = "PROVIDER=Micro soft.Jet.OLEDB. 4.0;DATA
SOURCE=" + Server.MapPath( "info.mdb") + ";";
OleDbConnection Conn = new OleDbConnection (strConn);
Conn.Open();
String strSQL = "SELECT * FROM Customers WHERE Login = '" + lg
+ "'";
OleDbCommand Cmd = new OleDbCommand(st rSQL, Conn);
OleDbDataReader Dr =
Cmd.ExecuteRead er(System.Data. CommandBehavior .CloseConnectio n);
if (Dr.HasRows)
{
args.IsValid = false;
} else args.IsValid = true;
Conn.Close();
}

Jun 22 '07 #1
5 3196
does your codebehind call Page.Validate?
-- bruce (sqlwork.com)

Dave wrote:
I've suprisingly not been able to find examples on this. I'm creating
a user account setup page, and the validators work fine on all the
other fields. But now I'm creating a customvalidator (for the first
time) and it is not doing anything. The page needs to see if a
username already exists. Am I doing this right?
<asp:textbox TabIndex="1" ID="tLogin" MaxLength="40" runat="server" />
<asp:customvali dator id="Customvalid ator1" runat="server"
EnableClientScr ipt="False" Font-Bold="True" ErrorMessage="U sername
already exists." ControlToValida te="tLogin"
OnServerValidat e="CheckUser" Display="Dynami c"/>

void CheckUser(objec t source,
System.Web.UI.W ebControls.Serv erValidateEvent Args args)
{
TextBox b;
b = fLogin.FindCont rol("tLogin") as TextBox;
String lg = b.Text;
String strConn = "PROVIDER=Micro soft.Jet.OLEDB. 4.0;DATA
SOURCE=" + Server.MapPath( "info.mdb") + ";";
OleDbConnection Conn = new OleDbConnection (strConn);
Conn.Open();
String strSQL = "SELECT * FROM Customers WHERE Login = '" + lg
+ "'";
OleDbCommand Cmd = new OleDbCommand(st rSQL, Conn);
OleDbDataReader Dr =
Cmd.ExecuteRead er(System.Data. CommandBehavior .CloseConnectio n);
if (Dr.HasRows)
{
args.IsValid = false;
} else args.IsValid = true;
Conn.Close();
}
Jun 22 '07 #2
On Jun 22, 2:27 pm, bruce barker <nos...@nospam. comwrote:
does your codebehind call Page.Validate?

-- bruce (sqlwork.com)

Dave wrote:
I've suprisingly not been able to find examples on this. I'm creating
a user account setup page, and the validators work fine on all the
other fields. But now I'm creating a customvalidator (for the first
time) and it is not doing anything. The page needs to see if a
username already exists. Am I doing this right?
<asp:textbox TabIndex="1" ID="tLogin" MaxLength="40" runat="server" />
<asp:customvali dator id="Customvalid ator1" runat="server"
EnableClientScr ipt="False" Font-Bold="True" ErrorMessage="U sername
already exists." ControlToValida te="tLogin"
OnServerValidat e="CheckUser" Display="Dynami c"/>
void CheckUser(objec t source,
System.Web.UI.W ebControls.Serv erValidateEvent Args args)
{
TextBox b;
b = fLogin.FindCont rol("tLogin") as TextBox;
String lg = b.Text;
String strConn = "PROVIDER=Micro soft.Jet.OLEDB. 4.0;DATA
SOURCE=" + Server.MapPath( "info.mdb") + ";";
OleDbConnection Conn = new OleDbConnection (strConn);
Conn.Open();
String strSQL = "SELECT * FROM Customers WHERE Login = '" + lg
+ "'";
OleDbCommand Cmd = new OleDbCommand(st rSQL, Conn);
OleDbDataReader Dr =
Cmd.ExecuteRead er(System.Data. CommandBehavior .CloseConnectio n);
if (Dr.HasRows)
{
args.IsValid = false;
} else args.IsValid = true;
Conn.Close();
}- Hide quoted text -

- Show quoted text -
No.

Jun 22 '07 #3
Actually even when I set the custom event handler to just return
false, it still does not kick in with the error message. Why isn't it
doing anything? Any help would be appreciated.

Jun 22 '07 #4
Nevermind, I gave up on the server side customvalidator and placed the
query code in the submit button handler.

Jun 22 '07 #5
Custom Validator ServerValidate event will not fire if text is empty. By
default ValidateEmptyTe xt property is set to False. Set it to true and try
again.
--
Programmer
"Dave" wrote:
I've suprisingly not been able to find examples on this. I'm creating
a user account setup page, and the validators work fine on all the
other fields. But now I'm creating a customvalidator (for the first
time) and it is not doing anything. The page needs to see if a
username already exists. Am I doing this right?
<asp:textbox TabIndex="1" ID="tLogin" MaxLength="40" runat="server" />
<asp:customvali dator id="Customvalid ator1" runat="server"
EnableClientScr ipt="False" Font-Bold="True" ErrorMessage="U sername
already exists." ControlToValida te="tLogin"
OnServerValidat e="CheckUser" Display="Dynami c"/>

void CheckUser(objec t source,
System.Web.UI.W ebControls.Serv erValidateEvent Args args)
{
TextBox b;
b = fLogin.FindCont rol("tLogin") as TextBox;
String lg = b.Text;
String strConn = "PROVIDER=Micro soft.Jet.OLEDB. 4.0;DATA
SOURCE=" + Server.MapPath( "info.mdb") + ";";
OleDbConnection Conn = new OleDbConnection (strConn);
Conn.Open();
String strSQL = "SELECT * FROM Customers WHERE Login = '" + lg
+ "'";
OleDbCommand Cmd = new OleDbCommand(st rSQL, Conn);
OleDbDataReader Dr =
Cmd.ExecuteRead er(System.Data. CommandBehavior .CloseConnectio n);
if (Dr.HasRows)
{
args.IsValid = false;
} else args.IsValid = true;
Conn.Close();
}

Jun 22 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1820
by: Wayne Gibson | last post by:
Hi all, Please ignore the other post.. The cat jumped on the machine and sent it before I could stop it!! Was wondering if anybody has expericence this problem.. I am writting an application in C# using windows forms, to create windows user profiles and then updating the registry information for the new profiles. I have managed to create the user successfully and thought that I was
2
3095
by: Sandman | last post by:
Just looking for suggestion on how to do this in my Web application. The goal is to keep track of what a user has and hasn't read and present him or her with new material I am currently doing this by aggregating new content from all databases into a single indexed database and then saving a timestamp in the account database (for the current user) that tells me when the user last read items in the aggregated database.
11
2166
by: Marcelo López | last post by:
I need to create a folder in the file system owned by an special user created by my application. The idea is that only my app will have permissions to delete and create files on that folder. My app is a redistribuitable one, so i need to create the user and give permissions to my app to that folder programatically. My questions are: 1) Using c# how can i create a new user account 2) How can i asign permissions to a folder to the new...
10
5516
by: Rigs | last post by:
Hi, I have a textbox with a Custom Validator that utilizes the OnServerValidate method for that textbox. This works fine, however the method only executes when data exists in that textbox after the Submit button is clicked. If I click the submit button and no data exists in the textbox, the OnServerValidate method does not fire. I'd like the OnServerValidate method to either execute every time the Submit button is clicked. I am...
3
1452
by: Brent Burkart | last post by:
I have a web application which consist of a huge form with many requiredfieldvalidators. Before the user submits, I want to prompt the user to print. I have tried to do this with the help of a CustomValidator and javascript, but I can't get the CustomValidator to fire. Does anyone have a better to approach this or maybe you can point me in the right direction as to why my CustomValidator is not working? Here is the code.
5
4074
by: Roshan | last post by:
Hi, Given a name, I want to be able to detect if a user or a group account exists with that name on a system and know if its a user or a group. My search yielded the "LookupAccountName" Win32 API but I haven't found any class in .NET that allows me to do that. Does any one know of a class in .NET or a way of doing this without using Win32 APIs ?
0
5296
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all the days in the week with dates and textboxes to fill in some data. row 1: question
1
1975
by: Carlettus | last post by:
Dear All, sorry but I'm not sure if this is the right place to post my problem. I was using the following asp code to create users in Active Directory. Suddenly, and I don't know the reason, users are created but the account is disabled (see the flag User.AccountDisabled = False ). There is also another problem even if the user does not exist , the application returns to me with the message that the user already exist. Thank you for...
3
2523
by: shapper | last post by:
Hello, On my web site I have a property, Visitor, which is available for Anonymous users: public class Visitor { public CultureInfo Culture { get; set; } public List<GuidPolls { get; set; } }
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9602
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10639
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7661
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.