Playing with Razor in Umbraco : an old skool contact form

Standard

This is clearly not the way a state of the art contact form should be made in Umbraco. But to learn and have fun with the new Razor possibilities I created a very basic contact form:

Edit : please also see this newer article about how to make a simple contact form with better code structure.

Here’s the complete code

@if (!IsPost)
{
    <form method="POST">
    Tell us what you think:<br/><textarea name="msg" rows="3" cols="40"></textarea><br/>
    Your name:<br/><input type="text" name="name"/><br/>
    <input type="submit" value="Send your message to us"/>
    </form>
}
else
{
    var message = Request["msg"];
    var name = Request["name"];
    umbraco.library.SendMail("from@mysite.com","to@mysite.com","Message from " + name,message,false);
    <strong>Thank you for your message @name:</strong><br/>@message
}
About these ads

7 thoughts on “Playing with Razor in Umbraco : an old skool contact form

  1. Petr

    Adding functions was possible long time ago using script runat server like this (I use it a lot):

    <script runat=”server”>
    public int GetLevel() {
    string path = umbraco.presentation.nodeFactory.Node.GetCurrent().Path;
    int count = 0;
    foreach (char c in path)
    if (c == ‘,’) count++;
    return count;
    }
    </script>

  2. internet

    Suppose you now have a solid hosting provider and offers amazing service but still your page speed
    loading time is much more. Search engines
    are far more ‘intelligent’ today and effective SEO requires actual meaningful content
    pages, social networking, articles submissions, and a
    focused marketing effort. This plugin will help you by
    automatically optimizing your titles so search engines can identify the keywords people are searching
    in your title for each blog post.

  3. of course like your web-site however you have to test
    the spelling on quite a few of your posts. A number of them are rife with spelling issues and I in finding
    it very bothersome to tell the truth nevertheless I’ll definitely come back again.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s