I created in web developer custom contact form with a few valildation controls. the form works ok apart from these validation control. I use following markup:
Hard to tell what's wrong if you don't provide any more info on what's going wrong? Does it do nothing? Do you get a runtime error? Context? Give us some more details and we might be able to help!
The data that user puts into the form is used to create a message and validation controls I use "force" the user to put an email for example as well as the message. When I complete the form correctly (by putting everything that is needed) and send the form it works OK. When I leave email texbox blank I get this exception:
The parameter 'from' cannot be an empty string.
Parameter name: from
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.
Exception Details: System.ArgumentException: The parameter 'from' cannot be an empty string.
Parameter name: from
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: The parameter 'from' cannot be an empty string.
Yeah sounds like your validation isn't running, if the form you're validating is running in the website itself (the frontend), and this is not a usercontrol used for the Umbraco backend, it should be possible to use asp.net validation. some things to check:
Is there a <form runat="server"> tag around your form on either a masterpage or the usercontrol you're developing
Do you check the validation in the server side code using a if (Page.IsValid) construct before trying to send the mail using the contents of the form?
Do the button you're using to post the form have a CausesValidation="false" attribute?
The code is within form tag and the CausesValidation attribute is set to "True" - exactly the same form runs OK on pure aspx site and the validation controls there work. I have no idea why it won't run under umbraco. I thought there are some special requirements ....
.net validation controls
Hello guys,
I created in web developer custom contact form with a few valildation controls. the form works ok apart from these validation control. I use following markup:
<p>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Email"
ErrorMessage="Please put your email."></asp:RequiredFieldValidator>
</p>
Why they do not work?
regards
Hard to tell what's wrong if you don't provide any more info on what's going wrong? Does it do nothing? Do you get a runtime error? Context? Give us some more details and we might be able to help!
Cheers,
/Dirk
hi Dirk,
Sorry for that.
The data that user puts into the form is used to create a message and validation controls I use "force" the user to put an email for example as well as the message. When I complete the form correctly (by putting everything that is needed) and send the form it works OK. When I leave email texbox blank I get this exception:
The parameter 'from' cannot be an empty string.
Parameter name: from
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.
Exception Details: System.ArgumentException: The parameter 'from' cannot be an empty string.
Parameter name: from
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: The parameter 'from' cannot be an empty string.
Parameter name: from]
System.Net.Mail.MailMessage..ctor(String from, String to) +1104873
System.Net.Mail.MailMessage..ctor(String from, String to, String subject, String body) +15
dodaj_gre.dodaj_gre.SendMail(String from, String to, String subject, String body) +102
dodaj_gre.dodaj_gre.submitButton_Click(Object sender, EventArgs e) +400
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
In other words the validation do not work. I am pretty sure that both bin and ascx files are correct.
I have a few similar forms on pure aspx and they do not let me send anything unless I put correct data.
Are validation controls different in umbraco than any other standard asp.net controls?
Hi pikej,
Yeah sounds like your validation isn't running, if the form you're validating is running in the website itself (the frontend), and this is not a usercontrol used for the Umbraco backend, it should be possible to use asp.net validation. some things to check:
Regards
Jesper Hauge
Hi Jesper, thanks a lot for your answer
The code is within form tag and the CausesValidation attribute is set to "True" - exactly the same form runs OK on pure aspx site and the validation controls there work. I have no idea why it won't run under umbraco. I thought there are some special requirements ....
Any other ideas?
regards,
pikej
Hi pikej,
Maybe you could post the code for the control or masterpage containing the form, both the markup and the code?
Regards
Jesper Hauge
is working on a reply...