Error: The parameter 'addresses' cannot be an empty string.
-
Hello The above is the error message I am getting followed by a long Stack Trace. I have a small form here http://www.dimadayoub.net/contact.aspx[^] and, to test it, I leave the email field blank on purpose (when I do the same for the other two fields, Name and Message, I get an on screen warning to complete the fields - which is what should happen). When I do the same with the email field, I get the above server error. The relevant code I have is this:
What should I be correcting, please?
-
Hello The above is the error message I am getting followed by a long Stack Trace. I have a small form here http://www.dimadayoub.net/contact.aspx[^] and, to test it, I leave the email field blank on purpose (when I do the same for the other two fields, Name and Message, I get an on screen warning to complete the fields - which is what should happen). When I do the same with the email field, I get the above server error. The relevant code I have is this:
What should I be correcting, please?
Remove the
ValidationGroup="vgSubmit"
attribute from both validators. Neither of your other validators have a validation group set, and neither does your submit button. Specifying Validation Groups | MSDN[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Remove the
ValidationGroup="vgSubmit"
attribute from both validators. Neither of your other validators have a validation group set, and neither does your submit button. Specifying Validation Groups | MSDN[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Many thanks, Richard, for your reply. I have done as you suggested and made a couple of other alterations. The code now looks like this:
The result is that when I complete the 3 fields correctly, the form is sent. When I complete the Name and Message fields, and Email field (without the @), I get an on screen error: 'Please complete the Email field' (for some reason it is in a white font and not the red of ="#FF6666"). I will amend that so it reads 'Please enter a valid email address'. When I leave the email field blank entirely (the form does not get sent, which is fine), but I can see a little asterisk. I presume that asterisk is this:
ErrorMessage="*"
Can I not replace that asterisk with the on screen message: 'Please complete the Email field'? Thanks again.
-
Many thanks, Richard, for your reply. I have done as you suggested and made a couple of other alterations. The code now looks like this:
The result is that when I complete the 3 fields correctly, the form is sent. When I complete the Name and Message fields, and Email field (without the @), I get an on screen error: 'Please complete the Email field' (for some reason it is in a white font and not the red of ="#FF6666"). I will amend that so it reads 'Please enter a valid email address'. When I leave the email field blank entirely (the form does not get sent, which is fine), but I can see a little asterisk. I presume that asterisk is this:
ErrorMessage="*"
Can I not replace that asterisk with the on screen message: 'Please complete the Email field'? Thanks again.
The
ErrorMessage
is the message that gets displayed in theValidationSummary
. TheText
is the message that gets displayed in-line. If you set theErrorMessage
without setting theText
, the same message is used in both places. You've usedDisplay="None"
, so the validators aren't showing up in-line. Instead, theValidationSummary
is showing all of the error messages next to the email field. You haven't applied any styles to theValidationSummary
, which is why the messages are white. I'd be inclined to put a singleValidationSummary
at the top of your form. Then, for each validator, set theErrorMessage
to the message you want to display, theText
to*
, and theDisplay
toDynamic
.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
The
ErrorMessage
is the message that gets displayed in theValidationSummary
. TheText
is the message that gets displayed in-line. If you set theErrorMessage
without setting theText
, the same message is used in both places. You've usedDisplay="None"
, so the validators aren't showing up in-line. Instead, theValidationSummary
is showing all of the error messages next to the email field. You haven't applied any styles to theValidationSummary
, which is why the messages are white. I'd be inclined to put a singleValidationSummary
at the top of your form. Then, for each validator, set theErrorMessage
to the message you want to display, theText
to*
, and theDisplay
toDynamic
.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Thanks again. I think I am beginning to see what you mean - it will take some time for me to digest all your kind points. Yes, I can make those changes and see the results. Do you mean apply CSS to ValidationSummary1, and not RegularExpressionValidator2, in order to add style to 'Please complete the Email field'?
-
Thanks again. I think I am beginning to see what you mean - it will take some time for me to digest all your kind points. Yes, I can make those changes and see the results. Do you mean apply CSS to ValidationSummary1, and not RegularExpressionValidator2, in order to add style to 'Please complete the Email field'?
You need to add style to both - the style on the
ValidationSummary
will apply to the summary messages at the top of the form, and the style on the individual validators will apply to the "*" that appears next to an invalid field. I generally use a theme[^] folder with a.skin
file to apply the sameCssClass
to all validators, and aCssClass
to theValidationSummary
. That way, the settings are consistent across the site, and the style settings remain in the CSS file where they belong. If you don't want to add a theme to your site, you'll need to set theCssClass
on each validator andValidationSummary
wherever you use them.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
You need to add style to both - the style on the
ValidationSummary
will apply to the summary messages at the top of the form, and the style on the individual validators will apply to the "*" that appears next to an invalid field. I generally use a theme[^] folder with a.skin
file to apply the sameCssClass
to all validators, and aCssClass
to theValidationSummary
. That way, the settings are consistent across the site, and the style settings remain in the CSS file where they belong. If you don't want to add a theme to your site, you'll need to set theCssClass
on each validator andValidationSummary
wherever you use them.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Yes, there is a theme to the site: www.dimadayoub.net[^], so the style would need to be consistent. Because space there is limited - the form is small - I was thinking of displaying the error messages in the form fields themselves. My CSS is not that good to do that - not sure it can be done in HTML/CSS alone. Grateful for your time.