Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • pikej 27 posts 47 karma points
    May 30, 2011 @ 17:04
    pikej
    0

    .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

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 30, 2011 @ 19:55
    Dirk De Grave
    0

    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

  • pikej 27 posts 47 karma points
    May 30, 2011 @ 20:23
    pikej
    0

    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?

     

  • Jesper Hauge 298 posts 487 karma points c-trib
    May 30, 2011 @ 21:48
    Jesper Hauge
    0

    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:

    1. Is there a <form runat="server"> tag around your form on either a masterpage or the usercontrol you're developing
    2. 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?
    3. Do the button you're using to post the form have a CausesValidation="false" attribute?

    Regards
    Jesper Hauge

  • pikej 27 posts 47 karma points
    May 30, 2011 @ 21:59
    pikej
    0

    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

  • Jesper Hauge 298 posts 487 karma points c-trib
    May 31, 2011 @ 08:32
    Jesper Hauge
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft