By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,207 Members | 1,065 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,207 IT Pros & Developers. It's quick & easy.

Custom validator doesnt show error message but shows server error

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.