Saturday, March 31, 2012
Strange Behavior from RequiredFieldValidator (and Two LinkButtons)
RequireFieldValidator. The situation is: the user needs to enter a folder
name in the TextBox and click the first LinkButton (the Create Folder
LinkButton) to create the folder. Then once that's done, they need to click
the second LinkButton (the Next LinkButton) to go to the next page (a
rudimentary wizard).
The RequiredFieldValidator is there to make sure the user enters a folder
name in the TextBox before clicking the first LinkButton (the Create Folder
LinkButton). This all works fine.
What's strange is if the user doesn't enter anything in the TextBox and
clicks the second LinkButton (the Next LinkButton) before clicking the first
LinkButton (the Create Folder LinkButton), the RequiredFieldValidator alarms
the error anyway.
Is this correct behavior? What we want is for the first LinkButton (the
Create Report LinkButton) only to validate that text has been entered in the
TextBox, not the second LinkButton (the Next LinkButton). How can we do
this?Hi JJ,
The function of the requiredfield validator is just to check the txtbox is
having some value or not.
If you want that checking has to be made only for the first link button and
not for the second link button, then specifically you have to inform the
validator as follows.
1. Click the second link button and go to the properties window.
2. Set the cause validation property to False.
So, here after when you are click second link button form will not do any
validations.
Hope this helps you.
Cheers,
Jerome. M
"JJ" wrote:
> We have an ASP.NET web form with 1 TextBox, 2 LinkButtons, and 1
> RequireFieldValidator. The situation is: the user needs to enter a folder
> name in the TextBox and click the first LinkButton (the Create Folder
> LinkButton) to create the folder. Then once that's done, they need to cli
ck
> the second LinkButton (the Next LinkButton) to go to the next page (a
> rudimentary wizard).
> The RequiredFieldValidator is there to make sure the user enters a folder
> name in the TextBox before clicking the first LinkButton (the Create Folde
r
> LinkButton). This all works fine.
> What's strange is if the user doesn't enter anything in the TextBox and
> clicks the second LinkButton (the Next LinkButton) before clicking the fir
st
> LinkButton (the Create Folder LinkButton), the RequiredFieldValidator alar
ms
> the error anyway.
> Is this correct behavior? What we want is for the first LinkButton (the
> Create Report LinkButton) only to validate that text has been entered in t
he
> TextBox, not the second LinkButton (the Next LinkButton). How can we do
> this?
>
>
Strange Behavior from RequiredFieldValidator (and Two LinkButtons)
RequireFieldValidator. The situation is: the user needs to enter a folder
name in the TextBox and click the first LinkButton (the Create Folder
LinkButton) to create the folder. Then once that's done, they need to click
the second LinkButton (the Next LinkButton) to go to the next page (a
rudimentary wizard).
The RequiredFieldValidator is there to make sure the user enters a folder
name in the TextBox before clicking the first LinkButton (the Create Folder
LinkButton). This all works fine.
What's strange is if the user doesn't enter anything in the TextBox and
clicks the second LinkButton (the Next LinkButton) before clicking the first
LinkButton (the Create Folder LinkButton), the RequiredFieldValidator alarms
the error anyway.
Is this correct behavior? What we want is for the first LinkButton (the
Create Report LinkButton) only to validate that text has been entered in the
TextBox, not the second LinkButton (the Next LinkButton). How can we do
this?Hi JJ,
The function of the requiredfield validator is just to check the txtbox is
having some value or not.
If you want that checking has to be made only for the first link button and
not for the second link button, then specifically you have to inform the
validator as follows.
1. Click the second link button and go to the properties window.
2. Set the cause validation property to False.
So, here after when you are click second link button form will not do any
validations.
Hope this helps you.
Cheers,
Jerome. M
"JJ" wrote:
> We have an ASP.NET web form with 1 TextBox, 2 LinkButtons, and 1
> RequireFieldValidator. The situation is: the user needs to enter a folder
> name in the TextBox and click the first LinkButton (the Create Folder
> LinkButton) to create the folder. Then once that's done, they need to click
> the second LinkButton (the Next LinkButton) to go to the next page (a
> rudimentary wizard).
> The RequiredFieldValidator is there to make sure the user enters a folder
> name in the TextBox before clicking the first LinkButton (the Create Folder
> LinkButton). This all works fine.
> What's strange is if the user doesn't enter anything in the TextBox and
> clicks the second LinkButton (the Next LinkButton) before clicking the first
> LinkButton (the Create Folder LinkButton), the RequiredFieldValidator alarms
> the error anyway.
> Is this correct behavior? What we want is for the first LinkButton (the
> Create Report LinkButton) only to validate that text has been entered in the
> TextBox, not the second LinkButton (the Next LinkButton). How can we do
> this?
>
Thursday, March 22, 2012
Strange NULL value behaviour / RequiredFieldValidator
Im puzzled by a NULL behaviour in SQL 2000 server.
There is a column in the table that does not allow NULL.
During data mining, the staff noted that, for that particular column, there
are a few records that are empty.
I do not specifically know whether they are "alt + 0160" character.
What are the reasons that can cause this to happen?
Validation front end, I've used ASP.NET's REQUIREDFIELDVALIDATOR on the
control to ensure that the field is compulsory
On the application scripting, I've the following to cleanse the data before
the data goes into the database:
cmd.Parameters.Add("@dotnet.itags.org.STREET_NAME", Data.SqlDbType.VarChar)
cmd.Parameters("@dotnet.itags.org.STREET_NAME").Value =
ReplaceSingleQuote(streetname.Text.Trim())
The function is:
Public Shared Function ReplaceSingleQuote(ByVal x As String)
If x = "" Then
Return x
End If
x = x.Replace("'", "''")
Return x
End Function
Posted Via Usenet.com Premium Usenet Newsgroup Services
------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
------------------
http://www.usenet.comHowdy,
I see you're using Parameters so you don't need to replace any characters as
SqlParameter is responsible for that. It's only required if you build queries
through concatenation. I suspect all single quotes have been turned to doule
quotes (see it in the database). Anyway, it seems there's something wrong
with your validation as empty entries are submited.
Regards
--
Milosz
"Eric Layman" wrote:
Quote:
Originally Posted by
Hi everyone,
>
Im puzzled by a NULL behaviour in SQL 2000 server.
>
There is a column in the table that does not allow NULL.
>
During data mining, the staff noted that, for that particular column, there
are a few records that are empty.
>
I do not specifically know whether they are "alt + 0160" character.
>
What are the reasons that can cause this to happen?
>
>
Validation front end, I've used ASP.NET's REQUIREDFIELDVALIDATOR on the
control to ensure that the field is compulsory
>
On the application scripting, I've the following to cleanse the data before
the data goes into the database:
>
cmd.Parameters.Add("@.STREET_NAME", Data.SqlDbType.VarChar)
cmd.Parameters("@.STREET_NAME").Value =
ReplaceSingleQuote(streetname.Text.Trim())
>
The function is:
>
Public Shared Function ReplaceSingleQuote(ByVal x As String)
>
If x = "" Then
Return x
End If
>
x = x.Replace("'", "''")
Return x
>
End Function
>
>
>
>
>
Posted Via Usenet.com Premium Usenet Newsgroup Services
------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
------------------
http://www.usenet.com
>
Thanks for the reply.
That's very weird.
I have no idea how to account for the blank columns!
She showed me the sql commands and that column is specifically set to NOT
NULL
She asked me "How did you do that?"
"Milosz Skalecki [MCAD]" <mily242@.DONTLIKESPAMwp.plwrote in message
news:F8096D27-F0D9-430B-9166-75518B2F4F98@.microsoft.com...
Quote:
Originally Posted by
Howdy,
>
I see you're using Parameters so you don't need to replace any characters
as
SqlParameter is responsible for that. It's only required if you build
queries
through concatenation. I suspect all single quotes have been turned to
doule
quotes (see it in the database). Anyway, it seems there's something wrong
with your validation as empty entries are submited.
>
Regards
--
Milosz
>
>
"Eric Layman" wrote:
>
Quote:
Originally Posted by
>Hi everyone,
>>
>Im puzzled by a NULL behaviour in SQL 2000 server.
>>
>There is a column in the table that does not allow NULL.
>>
>During data mining, the staff noted that, for that particular column,
>there
>are a few records that are empty.
>>
>I do not specifically know whether they are "alt + 0160" character.
>>
>What are the reasons that can cause this to happen?
>>
>>
>Validation front end, I've used ASP.NET's REQUIREDFIELDVALIDATOR on the
>control to ensure that the field is compulsory
>>
>On the application scripting, I've the following to cleanse the data
>before
>the data goes into the database:
>>
>cmd.Parameters.Add("@.STREET_NAME", Data.SqlDbType.VarChar)
>cmd.Parameters("@.STREET_NAME").Value =
>ReplaceSingleQuote(streetname.Text.Trim())
>>
>The function is:
>>
> Public Shared Function ReplaceSingleQuote(ByVal x As String)
>>
> If x = "" Then
> Return x
> End If
>>
> x = x.Replace("'", "''")
> Return x
>>
> End Function
>>
>>
>>
>>
>>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
>------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
>------------------
> http://www.usenet.com
>>
>
Posted Via Usenet.com Premium Usenet Newsgroup Services
------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
------------------
http://www.usenet.com
Hi Eric again,
Correct me if I'm wrong but you (or she) is confusing empty string with
NULL. NULL is a special value that simply indicates nothing is assigned,
whilst empty string is a correct value. Setting NOT NULL constraint to a
varchar column means NULL value is not allowed, but any other values (like
empty string '') are. Also check if there is a default value set for this
column. Anyway, from the code you posted, I suspect, there aren't data access
layer or business logic layers as you assign values directly from user
controls. This may indicate, operations on the table are performed in several
places differently (different logic?). In addition, do you use stored
procedures or plain text queries? If SPs, please confirm there is no logic
inside that inserts empty string in some cases. And the last tip, have you
checked if there are any triggers created on this table?
Regards
--
Milosz
"Eric Layman" wrote:
Quote:
Originally Posted by
Thanks for the reply.
>
That's very weird.
>
I have no idea how to account for the blank columns!
>
She showed me the sql commands and that column is specifically set to NOT
NULL
>
She asked me "How did you do that?"
>
>
>
"Milosz Skalecki [MCAD]" <mily242@.DONTLIKESPAMwp.plwrote in message
news:F8096D27-F0D9-430B-9166-75518B2F4F98@.microsoft.com...
Quote:
Originally Posted by
Howdy,
I see you're using Parameters so you don't need to replace any characters
as
SqlParameter is responsible for that. It's only required if you build
queries
through concatenation. I suspect all single quotes have been turned to
doule
quotes (see it in the database). Anyway, it seems there's something wrong
with your validation as empty entries are submited.
Regards
--
Milosz
"Eric Layman" wrote:
Quote:
Originally Posted by
Hi everyone,
>
Im puzzled by a NULL behaviour in SQL 2000 server.
>
There is a column in the table that does not allow NULL.
>
During data mining, the staff noted that, for that particular column,
there
are a few records that are empty.
>
I do not specifically know whether they are "alt + 0160" character.
>
What are the reasons that can cause this to happen?
>
>
Validation front end, I've used ASP.NET's REQUIREDFIELDVALIDATOR on the
control to ensure that the field is compulsory
>
On the application scripting, I've the following to cleanse the data
before
the data goes into the database:
>
cmd.Parameters.Add("@.STREET_NAME", Data.SqlDbType.VarChar)
cmd.Parameters("@.STREET_NAME").Value =
ReplaceSingleQuote(streetname.Text.Trim())
>
The function is:
>
Public Shared Function ReplaceSingleQuote(ByVal x As String)
>
If x = "" Then
Return x
End If
>
x = x.Replace("'", "''")
Return x
>
End Function
>
>
>
>
>
Posted Via Usenet.com Premium Usenet Newsgroup Services
------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
------------------
http://www.usenet.com
>
>
>
>
Posted Via Usenet.com Premium Usenet Newsgroup Services
------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
------------------
http://www.usenet.com
>
Run a test to see if there are actually NULLs in that column. Run the
following query:
SELECT *
FROM MyTable
WHERE MyColumn IS NULL
If you return rows then you have some NULLs in there and we'll need to
investigate how you got NULLs into a non-nullable column. If no rows are
returned then the column does not contain NULLs, and you need to determine
how you got zero-length strings into the column if you're not expecting them
to be there. If zero-length strings are being stored but are not
acceptable, you can add a check constraint like the following to the column:
CHECK(LEN(MyColumn) 0)
"Eric Layman" <namyalcire[at no spam]gmail.comwrote in message
news:1175766804_1545@.sp6iad.superfeed.net...
Quote:
Originally Posted by
Thanks for the reply.
>
That's very weird.
>
I have no idea how to account for the blank columns!
>
She showed me the sql commands and that column is specifically set to NOT
NULL
>
She asked me "How did you do that?"
>
>
>
"Milosz Skalecki [MCAD]" <mily242@.DONTLIKESPAMwp.plwrote in message
news:F8096D27-F0D9-430B-9166-75518B2F4F98@.microsoft.com...
Quote:
Originally Posted by
>Howdy,
>>
>I see you're using Parameters so you don't need to replace any characters
>as
>SqlParameter is responsible for that. It's only required if you build
>queries
>through concatenation. I suspect all single quotes have been turned to
>doule
>quotes (see it in the database). Anyway, it seems there's something wrong
>with your validation as empty entries are submited.
>>
>Regards
>--
>Milosz
>>
>>
>"Eric Layman" wrote:
>>
Quote:
Originally Posted by
>>Hi everyone,
>>>
>>Im puzzled by a NULL behaviour in SQL 2000 server.
>>>
>>There is a column in the table that does not allow NULL.
>>>
>>During data mining, the staff noted that, for that particular column,
>>there
>>are a few records that are empty.
>>>
>>I do not specifically know whether they are "alt + 0160" character.
>>>
>>What are the reasons that can cause this to happen?
>>>
>>>
>>Validation front end, I've used ASP.NET's REQUIREDFIELDVALIDATOR on the
>>control to ensure that the field is compulsory
>>>
>>On the application scripting, I've the following to cleanse the data
>>before
>>the data goes into the database:
>>>
>>cmd.Parameters.Add("@.STREET_NAME", Data.SqlDbType.VarChar)
>>cmd.Parameters("@.STREET_NAME").Value =
>>ReplaceSingleQuote(streetname.Text.Trim())
>>>
>>The function is:
>>>
>> Public Shared Function ReplaceSingleQuote(ByVal x As String)
>>>
>> If x = "" Then
>> Return x
>> End If
>>>
>> x = x.Replace("'", "''")
>> Return x
>>>
>> End Function
>>>
>>>
>>>
>>>
>>>
>> Posted Via Usenet.com Premium Usenet Newsgroup Services
>>------------------
>> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
>>------------------
>> http://www.usenet.com
>>>
>>
>
>
>
Posted Via Usenet.com Premium Usenet Newsgroup Services
------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
------------------
http://www.usenet.com
Strange NULL value behaviour / RequiredFieldValidator
Im puzzled by a NULL behaviour in SQL 2000 server.
There is a column in the table that does not allow NULL.
During data mining, the staff noted that, for that particular column, there
are a few records that are empty.
I do not specifically know whether they are "alt + 0160" character.
What are the reasons that can cause this to happen?
Validation front end, I've used ASP.NET's REQUIREDFIELDVALIDATOR on the
control to ensure that the field is compulsory
On the application scripting, I've the following to cleanse the data before
the data goes into the database:
cmd.Parameters.Add("@dotnet.itags.org.STREET_NAME", Data.SqlDbType.VarChar)
cmd.Parameters("@dotnet.itags.org.STREET_NAME").Value =
ReplaceSingleQuote(streetname.Text.Trim())
The function is:
Public Shared Function ReplaceSingleQuote(ByVal x As String)
If x = "" Then
Return x
End If
x = x.Replace("'", "''")
Return x
End Function
Posted Via mcse.ms Premium Usenet Newsgroup Services
----
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----
http://www.mcse.msHowdy,
I see you're using Parameters so you don't need to replace any characters as
SqlParameter is responsible for that. It's only required if you build querie
s
through concatenation. I suspect all single quotes have been turned to doule
quotes (see it in the database). Anyway, it seems there's something wrong
with your validation as empty entries are submited.
Regards
--
Milosz
"Eric Layman" wrote:
> Hi everyone,
> Im puzzled by a NULL behaviour in SQL 2000 server.
> There is a column in the table that does not allow NULL.
> During data mining, the staff noted that, for that particular column, ther
e
> are a few records that are empty.
> I do not specifically know whether they are "alt + 0160" character.
> What are the reasons that can cause this to happen?
>
> Validation front end, I've used ASP.NET's REQUIREDFIELDVALIDATOR on the
> control to ensure that the field is compulsory
> On the application scripting, I've the following to cleanse the data befor
e
> the data goes into the database:
> cmd.Parameters.Add("@.STREET_NAME", Data.SqlDbType.VarChar)
> cmd.Parameters("@.STREET_NAME").Value =
> ReplaceSingleQuote(streetname.Text.Trim())
> The function is:
> Public Shared Function ReplaceSingleQuote(ByVal x As String)
> If x = "" Then
> Return x
> End If
> x = x.Replace("'", "''")
> Return x
> End Function
>
>
> Posted Via mcse.ms Premium Usenet Newsgroup Services
> ----
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----
> http://www.mcse.ms
>
Thanks for the reply.
That's very weird.
I have no idea how to account for the blank columns!
She showed me the sql commands and that column is specifically set to NOT
NULL
She asked me "How did you do that?"
"Milosz Skalecki [MCAD]" <mily242@.DONTLIKESPAMwp.pl> wrote in message
news:F8096D27-F0D9-430B-9166-75518B2F4F98@.microsoft.com...
> Howdy,
> I see you're using Parameters so you don't need to replace any characters
> as
> SqlParameter is responsible for that. It's only required if you build
> queries
> through concatenation. I suspect all single quotes have been turned to
> doule
> quotes (see it in the database). Anyway, it seems there's something wrong
> with your validation as empty entries are submited.
> Regards
> --
> Milosz
>
> "Eric Layman" wrote:
>
>
Posted Via mcse.ms Premium Usenet Newsgroup Services
----
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----
http://www.mcse.ms
Hi Eric again,
Correct me if I’m wrong but you (or she) is confusing empty string with
NULL. NULL is a special value that simply indicates nothing is assigned,
whilst empty string is a correct value. Setting NOT NULL constraint to a
varchar column means NULL value is not allowed, but any other values (like
empty string '') are. Also check if there is a default value set for this
column. Anyway, from the code you posted, I suspect, there aren’t data acc
ess
layer or business logic layers as you assign values directly from user
controls. This may indicate, operations on the table are performed in severa
l
places differently (different logic?). In addition, do you use stored
procedures or plain text queries? If SPs, please confirm there is no logic
inside that inserts empty string in some cases. And the last tip, have you
checked if there are any triggers created on this table?
Regards
Milosz
"Eric Layman" wrote:
> Thanks for the reply.
> That's very weird.
> I have no idea how to account for the blank columns!
> She showed me the sql commands and that column is specifically set to NOT
> NULL
> She asked me "How did you do that?"
>
> "Milosz Skalecki [MCAD]" <mily242@.DONTLIKESPAMwp.pl> wrote in message
> news:F8096D27-F0D9-430B-9166-75518B2F4F98@.microsoft.com...
>
> Posted Via mcse.ms Premium Usenet Newsgroup Services
> ----
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----
> http://www.mcse.ms
>
Run a test to see if there are actually NULLs in that column. Run the
following query:
SELECT *
FROM MyTable
WHERE MyColumn IS NULL
If you return rows then you have some NULLs in there and we'll need to
investigate how you got NULLs into a non-nullable column. If no rows are
returned then the column does not contain NULLs, and you need to determine
how you got zero-length strings into the column if you're not expecting them
to be there. If zero-length strings are being stored but are not
acceptable, you can add a check constraint like the following to the column:
CHECK(LEN(MyColumn) > 0)
"Eric Layman" <namyalcire[at no spam]gmail.com> wrote in message
news:1175766804_1545@.sp6iad.superfeed.net...
> Thanks for the reply.
> That's very weird.
> I have no idea how to account for the blank columns!
> She showed me the sql commands and that column is specifically set to NOT
> NULL
> She asked me "How did you do that?"
>
> "Milosz Skalecki [MCAD]" <mily242@.DONTLIKESPAMwp.pl> wrote in message
> news:F8096D27-F0D9-430B-9166-75518B2F4F98@.microsoft.com...
>
> Posted Via mcse.ms Premium Usenet Newsgroup Services
> ----
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----
> http://www.mcse.ms