473,382 Members | 1,657 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,382 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 7797
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
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.