Copied to clipboard

Flag this post as spam?

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


  • BarneyHall 141 posts 210 karma points
    Sep 07, 2009 @ 09:10
    BarneyHall
    0

    CWS2 - adding an additional field to the contact form

    Hullo!

    I wonder if anyone can help me? Not being a C# programmer, I've made an attempt to add a "Telephone Number" field to the contact form included in Warren's CWS2 package, but I've hit a wall.

    I've managed to add the field to the form, and even the validation works. However, the new "telNumber" field is not written to either the generated email or the XML log.

    You can see the form on the development site here: http://dev.cityoflondonlocksmiths.co.uk/contact-us.aspx

    I've poured through it so many times now, I really can't see where I'm missing anything, but as I say I am not a C# coder!

    Please could anyone, with fresh eyes, have a look through and give me any pointers (see the links below).

    Any time that can generously be given to help me would really be appreciated. I feel it's so close, but I've fallen somewhere at the last fence...

    Huge thanks,
    Barney

    http://dl.getdropbox.com/u/1512180/ContactForm.ascx

    http://dl.getdropbox.com/u/1512180/ContactForm.ascx.cs

    http://dl.getdropbox.com/u/1512180/ContactForm.ascx.designer.cs

     

  • BarneyHall 141 posts 210 karma points
    Sep 07, 2009 @ 09:12
    BarneyHall
    0

    Looks like you need to copy and paste those links into your browser for them to work - cheers.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 07, 2009 @ 09:35
    Dirk De Grave
    0

    Only thing I can think of... Do you have the placeholder for the telephone number? Is is the correct casing?

     

    Cheers,

    /Dirk

     

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Sep 07, 2009 @ 09:36
    Warren Buckley
    0

    Having a quick skim through the code this seems fine. Did you build this into a DLL and drop it into the BIN directory?
    Did you update the XSLT to show the new field in /data/form_log.xslt ?

    Warren

  • ianhoughton 281 posts 605 karma points c-trib
    Sep 07, 2009 @ 09:46
    ianhoughton
    0

    In your code file I cannot see any reference at the top to the phonenumber string ?

    I changed the contact form on my siteto this, but it appears to be missing from yours...

    private string _EmailTo, _EmailSubject, _EmailBody, _EmailReplyFrom, _EmailReplySubject, _EmailReplyBody, _FormHeader, _FormText, _ThankYouHeaderText, _ThankYouMessageText, _PhoneNumber;
    public string PhoneNumber
                {
                    get
                    {
                        return _PhoneNumber;
                    }
                    set
                    {
                        _PhoneNumber = value;
                    }
                }
  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Sep 07, 2009 @ 10:07
    Warren Buckley
    0

    Hi Ian,
    The contact form doesnt really need that unless your passing in a value to PhoneNumber. For example all those variables are being passed into the macro from the current node with propertes on the document type to set the email to, email from, the email message etc...

    Warren

  • ianhoughton 281 posts 605 karma points c-trib
    Sep 07, 2009 @ 10:09
    ianhoughton
    0

    Ah my mistake then, just thought that was the only difference between our code.

  • BarneyHall 141 posts 210 karma points
    Sep 07, 2009 @ 10:11
    BarneyHall
    0

    @Dirk De Grave - yes I think I have maintained the casing. I've followed Warren's original fields and placeholders faithfully and cross referenced with against all the files.

    @Warren Buckley - no I haven't created a dll - it didn't look like it was compliled code (I'm very inexperienced in .net so tell me otherwise) - I couldn't find any references in /data/form_log.xslt other than when it calls <xsl:for-each select="field">, which are defined in your control.

    @ianhoughton - those strings are referencing the properties from Warren's document types. They're so the site admin can content manage the generated customer reply email - rather than the one created by the customer using the site enquiry form - if you folllow me?

    Cheers guys, appreciate your help. Hopefully some light will be thrown on this little nudget :)

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Sep 07, 2009 @ 10:15
    Warren Buckley
    0

    OK yes you won't need to update the XSLT then. It would be worth checking the XML file to see if your new field is being added at all.

    Yeh going from memory I dont think this is compiled code as I wanted easy for beginners to pickup/hack/learn.
    So replacing the .ascx and .ascx.cs should be ok for it to work.

    Warren

     

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Sep 07, 2009 @ 10:19
    Warren Buckley
    0

    Tested form and got your auto email reply sent to me so the rest of the logic is fine.

  • BarneyHall 141 posts 210 karma points
    Sep 07, 2009 @ 10:22
    BarneyHall
    0

    @Warren Buckley well I didn't check the XML and you're quite right it is being written to the XML, so it's just not being written to the email body- that narrows it down a bit !

    Also I guess I need to look at your dashboard control to display the telNumber within the Umbraco UI.

    Seems we're getting warmer! :)

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Sep 07, 2009 @ 10:30
    Warren Buckley
    0

    The dashboard will automatically show it as it uses the XSLT file that lists out every XML node that is a <field> node

    <xsl:for-each select="field">
      <li class="{@alias}">
         <xsl:value-of select="current()"/>
      </li>
    </xsl:for-each>

    So it should be showing up in the dashboard straight away - have you checked after I have sent you a test message from the form?

    And i have figured out why you are not getting your telephone number displayed in the email.
    http://dev.cityoflondonlocksmiths.co.uk/contact-us.aspx?umbDebugShowTrace=true

    Scroll down to the EmailBody property and you will see you have left out your placeholder for this property on your content node in umbraco, update the property in umbraco and save & publish ;)

    Warren :)

  • BarneyHall 141 posts 210 karma points
    Sep 07, 2009 @ 10:57
    BarneyHall
    0

    Ah ok, yes of course, the [TelNumber] placeholder needs to be on the content node!

    Looks like I need to amend the log_script.js and ContactForm_logs.ascx to get the logs to display on the dashboard.

    This great help. Many thanks!

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Sep 07, 2009 @ 11:00
    Warren Buckley
    0

    Not a problem dont forget to mark one of the replies as the solution. So everyone knows that is thread is solved/closed.

    Warren :)

  • Md Johirul Islam 37 posts 57 karma points
    Oct 13, 2011 @ 13:42
    Md Johirul Islam
    0

    Hi I am new in umbraco CMS .net controler. I am just wondering any one cal help me to create a customize Contact form by Web User control. I follow thw whole tutorial. But the problem is when i add valodation contron on my form. Then i found this erroe message...

     

    The ControlToValidate property of 'RequiredFieldValidator1' cannot be blank. and more ......

     

     

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ContactUsForm.ascx.cs" Inherits="ContactUsForm.ContactUsForm" %>

     

     <form action="" method="post" name="contactus">


    <table width="672" border="0" cellspacing="0" cellpadding="0">

              <tr>

                <td width="292"><input type="text" name="fname" id="fname" value="First Name"/><asp:RequiredFieldValidator 

                        ID="RequiredFieldValidator1" runat="server" 

                        ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>

                  </td>

                <td width="380" rowspan="6" valign="top"><table width="380" border="0" cellspacing="0" cellpadding="0" id="contact2">

                    <tr>

                      <td colspan="2"><textarea name="txtcomments" id="txtcomments" cols="45" rows="5">Enter text...</textarea></td>

                    </tr>

                    <tr>

                      <td width="187"><input name="Captcha" type="text" class="captcha" id="sml-input" value="78  BHG" /></td>

                      <td width="193"><span id="accessiblity">Ut et metus dapibus dolrutrum vestibulum molestie id ligula.</span></td>

                    </tr>

                    <tr>

                      <td colspan="2"><input name="sml-input" type="text" id="sml-input" value="Enter Code" /></td>

                    </tr>

                    <tr>

                      <td colspan="2"><a class="button" type="submit" href="#">Send Enquiry</a></td>

                    </tr>

                  </table></td>

              </tr>

              <tr>

                <td><input name="fname" type="text" id="lname" value="Last Name" /></td>

              </tr>

              <tr>

                <td><input name="company" type="text" id="company" value="Company Name" /></td>

              </tr>

              <tr>

                <td><input name="emailaddress" type="text" id="emailaddress" value="Email address" /></td>

              </tr>

              <tr>

                <td><select name="country" id="country">

                    <option>Please select your country</option>

                  </select></td>

              </tr>

              <tr>

                <td><label>

                    <input type="checkbox" name="chkmail" id="chkmail" />

                    I would like to receive relevant insight, news and reports from ICLP</label></td>

              </tr>

            </table>

            </form>


    Please give me an idea or anything else. Thank you.......

     

     

Please Sign in or register to post replies

Write your reply to:

Draft