473,231 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

Custom validator doesnt show error message but shows server error

Hi,

I am using a compare validator in asp.net application(c# code). This Custom
validator is used for comparing a value enterd by the user against the
primary key in the SQL database. IF the VALUE ENTERED BY THE USER EXISTS IN
THE DB , then THE ERROR MESSAGE OF THE COMPARE VALIDATOR SHOULD BE DISPLAYED.

For this, I used the reference artiicle
"http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/vbcon/html/vbtskvalidatingagainstvaluesindatabase.asp" .

But it doesnt work i.e, when i enter a value(which already exists in the
database) in the text box & hit submit, the Validation summary DOESNT SHOW
ERROR MESSAGE.
Instead, I get the error as::

Server Error in '/NEW' Application.

Violation of PRIMARY KEY constraint 'PK_FormFields'. Cannot insert duplicate
key in object 'FormFields'. The statement has been terminated.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

RATHER THAN THE USER BEING SHOWN THIS Server error page, I want the CUSTOM
VALIDATOR TO CHECK IF THE VALUE ALREADY EXISTS IN THE DATABASE,then THE
VALIDATION SUMMARY SHOULD SHOW ERROR.
My code is::

private void CustomValidator2_ServerValidate(object
source,System.Web.UI.WebControls.ServerValidateEve ntArgs args)
{
DataView dv= new DataView();
dv=dsValidate1.Tables[0].DefaultView;
string asi;
args.IsValid=true;
foreach(DataRowView datarow in dv)
{
// Extract asi from the current row
asi = datarow["Alias"].ToString();

// Compare asi against user's entry
if (asi == args.Value)
{
args.IsValid = false;
}
}
}

Any help is appreciated.

Thanks
--
pmud
Nov 19 '05 #1
8 7787
Obviously your validator never executes "args.IsValid = false;". I'd suggest
to set a breakpoint into the validator function to see why the comparison
never reaches the if-body.

Did you call Validate() at the beginning of your Page_Load() event?

HTH,
Axel Dahmen

--
www.sportbootcharter.com

-------------------
"pmud" <pm**@discussions.microsoft.com> schrieb im Newsbeitrag
news:E9**********************************@microsof t.com...
Hi,

I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the
primary key in the SQL database. IF the VALUE ENTERED BY THE USER EXISTS IN THE DB , then THE ERROR MESSAGE OF THE COMPARE VALIDATOR SHOULD BE DISPLAYED.
For this, I used the reference artiicle
"http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/vbcon/html/vbtskvalidatingagainstvaluesindatabase.asp" .

But it doesnt work i.e, when i enter a value(which already exists in the
database) in the text box & hit submit, the Validation summary DOESNT SHOW ERROR MESSAGE.
Instead, I get the error as::

Server Error in '/NEW' Application.

Violation of PRIMARY KEY constraint 'PK_FormFields'. Cannot insert duplicate key in object 'FormFields'. The statement has been terminated.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about the error and where it originated in the code.

RATHER THAN THE USER BEING SHOWN THIS Server error page, I want the CUSTOM VALIDATOR TO CHECK IF THE VALUE ALREADY EXISTS IN THE DATABASE,then THE
VALIDATION SUMMARY SHOULD SHOW ERROR.
My code is::

private void CustomValidator2_ServerValidate(object
source,System.Web.UI.WebControls.ServerValidateEve ntArgs args)
{
DataView dv= new DataView();
dv=dsValidate1.Tables[0].DefaultView;
string asi;
args.IsValid=true;
foreach(DataRowView datarow in dv)
{
// Extract asi from the current row
asi = datarow["Alias"].ToString();

// Compare asi against user's entry
if (asi == args.Value)
{
args.IsValid = false;
}
}
}

Any help is appreciated.

Thanks
--
pmud

Nov 19 '05 #2
you can try to put the code below to the event of submit.

if (Page.IsValid)
{
}

"pmud" wrote:
Hi,

I am using a compare validator in asp.net application(c# code). This Custom
validator is used for comparing a value enterd by the user against the
primary key in the SQL database. IF the VALUE ENTERED BY THE USER EXISTS IN
THE DB , then THE ERROR MESSAGE OF THE COMPARE VALIDATOR SHOULD BE DISPLAYED.

For this, I used the reference artiicle
"http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/vbcon/html/vbtskvalidatingagainstvaluesindatabase.asp" .

But it doesnt work i.e, when i enter a value(which already exists in the
database) in the text box & hit submit, the Validation summary DOESNT SHOW
ERROR MESSAGE.
Instead, I get the error as::

Server Error in '/NEW' Application.

Violation of PRIMARY KEY constraint 'PK_FormFields'. Cannot insert duplicate
key in object 'FormFields'. The statement has been terminated.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

RATHER THAN THE USER BEING SHOWN THIS Server error page, I want the CUSTOM
VALIDATOR TO CHECK IF THE VALUE ALREADY EXISTS IN THE DATABASE,then THE
VALIDATION SUMMARY SHOULD SHOW ERROR.
My code is::

private void CustomValidator2_ServerValidate(object
source,System.Web.UI.WebControls.ServerValidateEve ntArgs args)
{
DataView dv= new DataView();
dv=dsValidate1.Tables[0].DefaultView;
string asi;
args.IsValid=true;
foreach(DataRowView datarow in dv)
{
// Extract asi from the current row
asi = datarow["Alias"].ToString();

// Compare asi against user's entry
if (asi == args.Value)
{
args.IsValid = false;
}
}
}

Any help is appreciated.

Thanks
--
pmud

Nov 19 '05 #3
Hi Axel,

I just now added the Validate() function at the beginning of the page load().

Also, I inserted a breakpoint at the beginning of the custom validator's
event handler. But when I try to "Step Into" the code through the Debug tab,
the Step Into ,Step Over, StepOut or QuickWatch are all disabled. I think
the debugger is not properly installed or something. what do you think?

Is there any way to sove my problem of custom validator?

Thanks
Obviously your validator never executes "args.IsValid = false;". I'd suggest
to set a breakpoint into the validator function to see why the comparison
never reaches the if-body.

Did you call Validate() at the beginning of your Page_Load() event?

HTH,
Axel Dahmen

--
www.sportbootcharter.com

-------------------
"pmud" <pm**@discussions.microsoft.com> schrieb im Newsbeitrag
news:E9**********************************@microsof t.com...
Hi,

I am using a compare validator in asp.net application(c# code). This

Custom
validator is used for comparing a value enterd by the user against the
primary key in the SQL database. IF the VALUE ENTERED BY THE USER EXISTS

IN
THE DB , then THE ERROR MESSAGE OF THE COMPARE VALIDATOR SHOULD BE

DISPLAYED.

For this, I used the reference artiicle
"http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/vbcon/html/vbtskvalidatingagainstvaluesindatabase.asp" .

But it doesnt work i.e, when i enter a value(which already exists in the
database) in the text box & hit submit, the Validation summary DOESNT

SHOW
ERROR MESSAGE.
Instead, I get the error as::

Server Error in '/NEW' Application.

Violation of PRIMARY KEY constraint 'PK_FormFields'. Cannot insert

duplicate
key in object 'FormFields'. The statement has been terminated.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information

about
the error and where it originated in the code.

RATHER THAN THE USER BEING SHOWN THIS Server error page, I want the

CUSTOM
VALIDATOR TO CHECK IF THE VALUE ALREADY EXISTS IN THE DATABASE,then THE
VALIDATION SUMMARY SHOULD SHOW ERROR.
My code is::

private void CustomValidator2_ServerValidate(object
source,System.Web.UI.WebControls.ServerValidateEve ntArgs args)
{
DataView dv= new DataView();
dv=dsValidate1.Tables[0].DefaultView;
string asi;
args.IsValid=true;
foreach(DataRowView datarow in dv)
{
// Extract asi from the current row
asi = datarow["Alias"].ToString();

// Compare asi against user's entry
if (asi == args.Value)
{
args.IsValid = false;
}
}
}

Any help is appreciated.

Thanks
--
pmud


Nov 19 '05 #4
Hi Peng,

I tried if (Page.IsValid){} too. But it works as long as the user doesnt
enter a duplicate value. But when page is not valid, again the server error
is shown & nothing else.

I dont understand why the custom validator is not showing error message?

"Peng Jie" wrote:
you can try to put the code below to the event of submit.

if (Page.IsValid)
{
}

"pmud" wrote:
Hi,

I am using a compare validator in asp.net application(c# code). This Custom
validator is used for comparing a value enterd by the user against the
primary key in the SQL database. IF the VALUE ENTERED BY THE USER EXISTS IN
THE DB , then THE ERROR MESSAGE OF THE COMPARE VALIDATOR SHOULD BE DISPLAYED.

For this, I used the reference artiicle
"http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/vbcon/html/vbtskvalidatingagainstvaluesindatabase.asp" .

But it doesnt work i.e, when i enter a value(which already exists in the
database) in the text box & hit submit, the Validation summary DOESNT SHOW
ERROR MESSAGE.
Instead, I get the error as::

Server Error in '/NEW' Application.

Violation of PRIMARY KEY constraint 'PK_FormFields'. Cannot insert duplicate
key in object 'FormFields'. The statement has been terminated.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

RATHER THAN THE USER BEING SHOWN THIS Server error page, I want the CUSTOM
VALIDATOR TO CHECK IF THE VALUE ALREADY EXISTS IN THE DATABASE,then THE
VALIDATION SUMMARY SHOULD SHOW ERROR.
My code is::

private void CustomValidator2_ServerValidate(object
source,System.Web.UI.WebControls.ServerValidateEve ntArgs args)
{
DataView dv= new DataView();
dv=dsValidate1.Tables[0].DefaultView;
string asi;
args.IsValid=true;
foreach(DataRowView datarow in dv)
{
// Extract asi from the current row
asi = datarow["Alias"].ToString();

// Compare asi against user's entry
if (asi == args.Value)
{
args.IsValid = false;
}
}
}

Any help is appreciated.

Thanks
--
pmud

Nov 19 '05 #5
Are you compiling in debug mode or release mode?

It should be debug mode, and if you are trying to debug remotely on another
server, you must have installed remote debugging components.

bill

"pmud" <pm**@discussions.microsoft.com> wrote in message
news:37**********************************@microsof t.com...
Hi Axel,

I just now added the Validate() function at the beginning of the page load().
Also, I inserted a breakpoint at the beginning of the custom validator's
event handler. But when I try to "Step Into" the code through the Debug tab, the Step Into ,Step Over, StepOut or QuickWatch are all disabled. I think
the debugger is not properly installed or something. what do you think?

Is there any way to sove my problem of custom validator?

Thanks
Obviously your validator never executes "args.IsValid = false;". I'd suggest to set a breakpoint into the validator function to see why the comparison never reaches the if-body.

Did you call Validate() at the beginning of your Page_Load() event?

HTH,
Axel Dahmen

--
www.sportbootcharter.com

-------------------
"pmud" <pm**@discussions.microsoft.com> schrieb im Newsbeitrag
news:E9**********************************@microsof t.com...
Hi,

I am using a compare validator in asp.net application(c# code). This

Custom
validator is used for comparing a value enterd by the user against the
primary key in the SQL database. IF the VALUE ENTERED BY THE USER EXISTS
IN
THE DB , then THE ERROR MESSAGE OF THE COMPARE VALIDATOR SHOULD BE

DISPLAYED.

For this, I used the reference artiicle
"http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/vbcon/html/vbtskvalidatingagainstvaluesindatabase.asp" .

But it doesnt work i.e, when i enter a value(which already exists in
the database) in the text box & hit submit, the Validation summary DOESNT

SHOW
ERROR MESSAGE.
Instead, I get the error as::

Server Error in '/NEW' Application.

Violation of PRIMARY KEY constraint 'PK_FormFields'. Cannot insert

duplicate
key in object 'FormFields'. The statement has been terminated.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about
the error and where it originated in the code.

RATHER THAN THE USER BEING SHOWN THIS Server error page, I want the

CUSTOM
VALIDATOR TO CHECK IF THE VALUE ALREADY EXISTS IN THE DATABASE,then

THE VALIDATION SUMMARY SHOULD SHOW ERROR.
My code is::

private void CustomValidator2_ServerValidate(object
source,System.Web.UI.WebControls.ServerValidateEve ntArgs args)
{
DataView dv= new DataView();
dv=dsValidate1.Tables[0].DefaultView;
string asi;
args.IsValid=true;
foreach(DataRowView datarow in dv)
{
// Extract asi from the current row
asi = datarow["Alias"].ToString();

// Compare asi against user's entry
if (asi == args.Value)
{
args.IsValid = false;
}
}
}

Any help is appreciated.

Thanks
--
pmud


Nov 19 '05 #6
Hi,

I am not able to compile in the debug mode. I tried to ude the article
http://samples.gotdotnet.com/quickst...bugcomsdk.aspx for
this. Buw when I tried to run DbgClr.exe , i got an error as:: "Windows
cannot find the file DbgClr.exe..."

In case this is useful, VS.Net is installed on the server & I am using my
local machine for creating the applications. I am a part of the
administrators group too.

I remember, when installing VS.Net, I got some error for debugging
components & it said these components are not installed because of some
reason. What should I do? I dont want to uninstall & then reinstall .Net
again. I have already created an application using it. That application might
get affected, if I do it again?

Is there no other way of finding out why the custom validator is not showing
error when a duplicate value (which already exists in Db) is entered in the
text box?

what is the best thing to do. Please suggest.

"William F. Robertson, Jr." wrote:
Are you compiling in debug mode or release mode?

It should be debug mode, and if you are trying to debug remotely on another
server, you must have installed remote debugging components.

bill

"pmud" <pm**@discussions.microsoft.com> wrote in message
news:37**********************************@microsof t.com...
Hi Axel,

I just now added the Validate() function at the beginning of the page

load().

Also, I inserted a breakpoint at the beginning of the custom validator's
event handler. But when I try to "Step Into" the code through the Debug

tab,
the Step Into ,Step Over, StepOut or QuickWatch are all disabled. I think
the debugger is not properly installed or something. what do you think?

Is there any way to sove my problem of custom validator?

Thanks
Obviously your validator never executes "args.IsValid = false;". I'd suggest to set a breakpoint into the validator function to see why the comparison never reaches the if-body.

Did you call Validate() at the beginning of your Page_Load() event?

HTH,
Axel Dahmen

--
www.sportbootcharter.com

-------------------
"pmud" <pm**@discussions.microsoft.com> schrieb im Newsbeitrag
news:E9**********************************@microsof t.com...
> Hi,
>
> I am using a compare validator in asp.net application(c# code). This
Custom
> validator is used for comparing a value enterd by the user against the
> primary key in the SQL database. IF the VALUE ENTERED BY THE USER EXISTS IN
> THE DB , then THE ERROR MESSAGE OF THE COMPARE VALIDATOR SHOULD BE
DISPLAYED.
>
> For this, I used the reference artiicle
> "http://msdn.microsoft.com/library/default.asp?url=/library/en-
> us/vbcon/html/vbtskvalidatingagainstvaluesindatabase.asp" .
>
> But it doesnt work i.e, when i enter a value(which already exists in the > database) in the text box & hit submit, the Validation summary DOESNT
SHOW
> ERROR MESSAGE.
> Instead, I get the error as::
>
> Server Error in '/NEW' Application.
>
> Violation of PRIMARY KEY constraint 'PK_FormFields'. Cannot insert
duplicate
> key in object 'FormFields'. The statement has been terminated.
>
> Description: An unhandled exception occurred during the execution of the > current web request. Please review the stack trace for more information about
> the error and where it originated in the code.
>
> RATHER THAN THE USER BEING SHOWN THIS Server error page, I want the
CUSTOM
> VALIDATOR TO CHECK IF THE VALUE ALREADY EXISTS IN THE DATABASE,then THE > VALIDATION SUMMARY SHOULD SHOW ERROR.
>
>
> My code is::
>
> private void CustomValidator2_ServerValidate(object
> source,System.Web.UI.WebControls.ServerValidateEve ntArgs args)
> {
> DataView dv= new DataView();
> dv=dsValidate1.Tables[0].DefaultView;
> string asi;
> args.IsValid=true;
> foreach(DataRowView datarow in dv)
> {
> // Extract asi from the current row
> asi = datarow["Alias"].ToString();
>
> // Compare asi against user's entry
> if (asi == args.Value)
> {
> args.IsValid = false;
> }
> }
> }
>
> Any help is appreciated.
>
> Thanks
>
>
> --
> pmud


Nov 19 '05 #7
Well, I can assure you, nothing harmful will happen if you'll re-install VS.
I've done it approx. 300 times in the last couple of years because of a
defective VIA chip on my K7M mainboard (by design *sigh*) which kills my
hard-disk data every now and then, and the only thing I always have to redo
is the Options settings and some other personal adjustments.

On the other hand you could do what I do whenever I can't debug: Inject
trace information code in each line from the beginning of the event down to
the line you want to reach. You can use ASP.NET's tracing functionality.
This way you can find the erroneous line more or less easily - if you really
prefer to go through the pain of re-compiling after every change instead of
re-installing VS only once...

HTH,
Axel Dahmen

------------------------------
"pmud" <pm**@discussions.microsoft.com> schrieb im Newsbeitrag
news:1F**********************************@microsof t.com...
Hi,

I am not able to compile in the debug mode. I tried to ude the article
http://samples.gotdotnet.com/quickst...bugcomsdk.aspx for
this. Buw when I tried to run DbgClr.exe , i got an error as:: "Windows
cannot find the file DbgClr.exe..."

In case this is useful, VS.Net is installed on the server & I am using my
local machine for creating the applications. I am a part of the
administrators group too.

I remember, when installing VS.Net, I got some error for debugging
components & it said these components are not installed because of some
reason. What should I do? I dont want to uninstall & then reinstall .Net
again. I have already created an application using it. That application might get affected, if I do it again?

Is there no other way of finding out why the custom validator is not showing error when a duplicate value (which already exists in Db) is entered in the text box?

what is the best thing to do. Please suggest.

"William F. Robertson, Jr." wrote:
Are you compiling in debug mode or release mode?

It should be debug mode, and if you are trying to debug remotely on another server, you must have installed remote debugging components.

bill

"pmud" <pm**@discussions.microsoft.com> wrote in message
news:37**********************************@microsof t.com...
Hi Axel,

I just now added the Validate() function at the beginning of the page

load().

Also, I inserted a breakpoint at the beginning of the custom validator's event handler. But when I try to "Step Into" the code through the Debug
tab,
the Step Into ,Step Over, StepOut or QuickWatch are all disabled. I
think the debugger is not properly installed or something. what do you think?
Is there any way to sove my problem of custom validator?

Thanks

> Obviously your validator never executes "args.IsValid = false;". I'd

suggest
> to set a breakpoint into the validator function to see why the

comparison
> never reaches the if-body.
>
> Did you call Validate() at the beginning of your Page_Load() event?
>
> HTH,
> Axel Dahmen
>
> --
> www.sportbootcharter.com
>
> -------------------
> "pmud" <pm**@discussions.microsoft.com> schrieb im Newsbeitrag
> news:E9**********************************@microsof t.com...
> > Hi,
> >
> > I am using a compare validator in asp.net application(c# code). This > Custom
> > validator is used for comparing a value enterd by the user against the > > primary key in the SQL database. IF the VALUE ENTERED BY THE USER

EXISTS
> IN
> > THE DB , then THE ERROR MESSAGE OF THE COMPARE VALIDATOR SHOULD BE
> DISPLAYED.
> >
> > For this, I used the reference artiicle
> > "http://msdn.microsoft.com/library/default.asp?url=/library/en-
> > us/vbcon/html/vbtskvalidatingagainstvaluesindatabase.asp" .
> >
> > But it doesnt work i.e, when i enter a value(which already exists in the
> > database) in the text box & hit submit, the Validation summary
DOESNT > SHOW
> > ERROR MESSAGE.
> > Instead, I get the error as::
> >
> > Server Error in '/NEW' Application.
> >
> > Violation of PRIMARY KEY constraint 'PK_FormFields'. Cannot insert
> duplicate
> > key in object 'FormFields'. The statement has been terminated.
> >
> > Description: An unhandled exception occurred during the execution of the
> > current web request. Please review the stack trace for more

information
> about
> > the error and where it originated in the code.
> >
> > RATHER THAN THE USER BEING SHOWN THIS Server error page, I want
the > CUSTOM
> > VALIDATOR TO CHECK IF THE VALUE ALREADY EXISTS IN THE

DATABASE,then THE
> > VALIDATION SUMMARY SHOULD SHOW ERROR.
> >
> >
> > My code is::
> >
> > private void CustomValidator2_ServerValidate(object
> > source,System.Web.UI.WebControls.ServerValidateEve ntArgs args)
> > {
> > DataView dv= new DataView();
> > dv=dsValidate1.Tables[0].DefaultView;
> > string asi;
> > args.IsValid=true;
> > foreach(DataRowView datarow in dv)
> > {
> > // Extract asi from the current row
> > asi = datarow["Alias"].ToString();
> >
> > // Compare asi against user's entry
> > if (asi == args.Value)
> > {
> > args.IsValid = false;
> > }
> > }
> > }
> >
> > Any help is appreciated.
> >
> > Thanks
> >
> >
> > --
> > pmud
>
>
>


Nov 19 '05 #8
Hi Axel,

I did some research on Asp.net's Trace functionality. But i would need your
help with the code. I included trace= "true " in the page directive. Then
I added Trace.Write or Trace.Warn with the string message in it. But I cant
see those messages when i see the trace information through the browser.
Also, I see the trace information is overlapping my webform so i cant read
anything clearly.

My code is:
private void CustomValidator2_ServerValidate(object
source,System.Web.UI.WebControls.ServerValidateEve ntArgs args)
{
Trace.Write("isnside Custom validator");
DataView dv= new DataView();
dv=dsValidate1.Tables[0].DefaultView;
string asi;
args.IsValid=true;
Trace.Warn("before dataset");
foreach(DataRowView datarow in dv)
{
asi = datarow["Alias"].ToString();
Trace.Warn("dataset filled");
// Compare e-mail address against user's entry
if (asi == args.Value)
{
Trace.Warn("inside if");
args.IsValid = false;
//CustomValidator2.Visible=true;
}
else
{
args.IsValid=true;
}

}
}

What is wrong with this? Is there some better coding style for showing an
error message if the user tries to enter a value (which is a primary key of
the database) already exists in the database?


"Axel Dahmen" wrote:
Well, I can assure you, nothing harmful will happen if you'll re-install VS.
I've done it approx. 300 times in the last couple of years because of a
defective VIA chip on my K7M mainboard (by design *sigh*) which kills my
hard-disk data every now and then, and the only thing I always have to redo
is the Options settings and some other personal adjustments.

On the other hand you could do what I do whenever I can't debug: Inject
trace information code in each line from the beginning of the event down to
the line you want to reach. You can use ASP.NET's tracing functionality.
This way you can find the erroneous line more or less easily - if you really
prefer to go through the pain of re-compiling after every change instead of
re-installing VS only once...

HTH,
Axel Dahmen

------------------------------
"pmud" <pm**@discussions.microsoft.com> schrieb im Newsbeitrag
news:1F**********************************@microsof t.com...
Hi,

I am not able to compile in the debug mode. I tried to ude the article
http://samples.gotdotnet.com/quickst...bugcomsdk.aspx for
this. Buw when I tried to run DbgClr.exe , i got an error as:: "Windows
cannot find the file DbgClr.exe..."

In case this is useful, VS.Net is installed on the server & I am using my
local machine for creating the applications. I am a part of the
administrators group too.

I remember, when installing VS.Net, I got some error for debugging
components & it said these components are not installed because of some
reason. What should I do? I dont want to uninstall & then reinstall .Net
again. I have already created an application using it. That application

might
get affected, if I do it again?

Is there no other way of finding out why the custom validator is not

showing
error when a duplicate value (which already exists in Db) is entered in

the
text box?

what is the best thing to do. Please suggest.

"William F. Robertson, Jr." wrote:
Are you compiling in debug mode or release mode?

It should be debug mode, and if you are trying to debug remotely on another server, you must have installed remote debugging components.

bill

"pmud" <pm**@discussions.microsoft.com> wrote in message
news:37**********************************@microsof t.com...
> Hi Axel,
>
> I just now added the Validate() function at the beginning of the page
load().
>
> Also, I inserted a breakpoint at the beginning of the custom validator's > event handler. But when I try to "Step Into" the code through the Debug tab,
> the Step Into ,Step Over, StepOut or QuickWatch are all disabled. I think > the debugger is not properly installed or something. what do you think? >
> Is there any way to sove my problem of custom validator?
>
> Thanks
>
> > Obviously your validator never executes "args.IsValid = false;". I'd
suggest
> > to set a breakpoint into the validator function to see why the
comparison
> > never reaches the if-body.
> >
> > Did you call Validate() at the beginning of your Page_Load() event?
> >
> > HTH,
> > Axel Dahmen
> >
> > --
> > www.sportbootcharter.com
> >
> > -------------------
> > "pmud" <pm**@discussions.microsoft.com> schrieb im Newsbeitrag
> > news:E9**********************************@microsof t.com...
> > > Hi,
> > >
> > > I am using a compare validator in asp.net application(c# code). This > > Custom
> > > validator is used for comparing a value enterd by the user against the > > > primary key in the SQL database. IF the VALUE ENTERED BY THE USER
EXISTS
> > IN
> > > THE DB , then THE ERROR MESSAGE OF THE COMPARE VALIDATOR SHOULD BE
> > DISPLAYED.
> > >
> > > For this, I used the reference artiicle
> > > "http://msdn.microsoft.com/library/default.asp?url=/library/en-
> > > us/vbcon/html/vbtskvalidatingagainstvaluesindatabase.asp" .
> > >
> > > But it doesnt work i.e, when i enter a value(which already exists in the
> > > database) in the text box & hit submit, the Validation summary DOESNT > > SHOW
> > > ERROR MESSAGE.
> > > Instead, I get the error as::
> > >
> > > Server Error in '/NEW' Application.
> > >
> > > Violation of PRIMARY KEY constraint 'PK_FormFields'. Cannot insert
> > duplicate
> > > key in object 'FormFields'. The statement has been terminated.
> > >
> > > Description: An unhandled exception occurred during the execution of the
> > > current web request. Please review the stack trace for more
information
> > about
> > > the error and where it originated in the code.
> > >
> > > RATHER THAN THE USER BEING SHOWN THIS Server error page, I want the > > CUSTOM
> > > VALIDATOR TO CHECK IF THE VALUE ALREADY EXISTS IN THE DATABASE,then THE
> > > VALIDATION SUMMARY SHOULD SHOW ERROR.
> > >
> > >
> > > My code is::
> > >
> > > private void CustomValidator2_ServerValidate(object
> > > source,System.Web.UI.WebControls.ServerValidateEve ntArgs args)
> > > {
> > > DataView dv= new DataView();
> > > dv=dsValidate1.Tables[0].DefaultView;
> > > string asi;
> > > args.IsValid=true;
> > > foreach(DataRowView datarow in dv)
> > > {
> > > // Extract asi from the current row
> > > asi = datarow["Alias"].ToString();
> > >
> > > // Compare asi against user's entry
> > > if (asi == args.Value)
> > > {
> > > args.IsValid = false;
> > > }
> > > }
> > > }
> > >
> > > Any help is appreciated.
> > >
> > > Thanks
> > >
> > >
> > > --
> > > pmud
> >
> >
> >


Nov 19 '05 #9

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

Similar topics

2
by: Pham Nguyen | last post by:
Has anyone seen an example of a textbox server control that has built-in client-side validation? I'd like to build a server control that extends the System.Web.UI.WebControls.TextBox class to allow...
1
by: z. f. | last post by:
in my custom validator ServerValidate function i set args.IsValid = False but the page execution continues like the page is valid and the validation summary doesn't show the error message . how...
1
by: Stephen Adam | last post by:
Hi there, I have written a custom validation control which checks to see of an input field is not empty and contains only numeric data. I was using a regular expression validation control but...
2
by: pmud | last post by:
Hi, I have an ASP.Net web page . The page was working fine until I added a required field field validator. My page has a link button which takes the user to another page, a submit button which...
1
by: Elie Medeiros via .NET 247 | last post by:
Hi there, I have written a custom validator function to validate a datefrom a user-filled field. The function tries to parse the dateand if it can't, sets (serverValidateEventArgs)e.IsValid...
6
by: dee | last post by:
Hi In web.config I have to the following: <configuration> <system.web> <customErrors defaultRedirect="error.htm" mode="On" /> </system.web> </configuration>
5
by: Mattyw | last post by:
Hi, I'm relatively new to Web Forms, I have been using Required Field Validators and Regular Expression Validators on a Web Form I am developing and everything works as expected using Visual...
2
by: Alan Silver | last post by:
Hello, I have a custom validator on my page, and have the server-side code working fine. I want to add a client-side funtion as well, but am not sure how to wire it in so that it works with the...
8
by: Radu | last post by:
Hi. I have an ASP control on my page: <asp:Calendar ID="calStart" ................ Etc </asp:Calendar> and I have a Custom Validator defined as <asp:CustomValidator
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.