Copied to clipboard

Flag this post as spam?

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


  • Tim 1 post 21 karma points
    Jun 07, 2015 @ 21:25
    Tim
    0

    Html.BeginUmbracoForm generates a blank action in <form>

    Hi together,

    i am pretty new in using Umbraco and i realy like the MVC architecture but i have got an issue with the Html.BeginUmbracoForm function.

    I follow this documentation but the result is a blank action property in the form tag.

    Detailed view on my method i was try to do it:

    First of all i have a @Html.Action("SaveInterestedEmail", "HomeSurface") in my Home.cshtml. This Action executes the following method:

    public class HomeSurfaceController : SurfaceController
    {
        [HttpGet]
        public ActionResult SaveInterestedEmail()
        {
            return this.PartialView("~/Views/Partials/_EmailForm.cshtml");
        }
    
        [HttpPost]
        public ActionResult SaveInterestedEmail(string email)
        {
            using (var db = new CustomDbContext())
            {
                db.With<InterestedUser>().Add(new InterestedUser { Email = email });
                db.SaveChanges();
            }
    
            return this.RedirectToCurrentUmbracoPage();
        }
    }
    

    As you see the first ActionResult is called which is responsible for rendering the PartialView _EmailForm.cshtml:

    @{
        using (Html.BeginUmbracoForm("SaveInterestedEmail", "HomeSurface", FormMethod.Post))
        {
            @Html.TextBox("Email", string.Empty, new { @class = "form-control", placeholder = "E-Mail Adresse" })
            <br />
            <input type="submit" value="Registrieren" class="btn btn-xl" />
        }
    }
    

    I expect that an email adress which was typed into a textbox is saved into the database. The textbox and the button is displayed correctly:

    email form

    But all i get in my form method is this:

    <form action="/" enctype="multipart/form-data" method="post"><input class="form-control" id="Email" name="Email" placeholder="E-Mail Adresse" type="text" value="" />        
    <br />
    <input type="submit" value="Registrieren" class="btn btn-xl" />
    <input name='ufprt' type='hidden' value='1D7DF080055B1D1363D9BE7AC84D81F7DF99CAB9C7A86276B149CBFDEE51932D5C1FB51892CF1ED7DFF7668B6898219DE06A2612B37D77040B9C85E4D652C4A45477EF25C87F69704334E15D30413C465B7141CBE7AE60A6FD2EFE81A3DCA497B5D86FEE740F8F7036550A3E0E74F00678743B6B1348904A9E76AB67FFEFE58899FF920CAE68D46A8CFDB2B7038D1CAC351B4D97E8F77F638D9787A459DA780E' />
    </form>
    

    So the result is a blank action property and the logical consequence is a button without any function. When i switch the Html.BeginUmbracoForm to Html.BeginForm i get this:

    <form action="/umbraco/Surface/HomeSurface/SaveInterestedEmail" method="post"><input class="form-control" id="Email" name="Email" placeholder="E-Mail Adresse" type="text" value="" />        <br />
            <input type="submit" value="Registrieren" class="btn btn-xl" />
    </form>
    

    But the action is still without any function. Apart from my public ActionResult SaveInterestedEmail(string email) function whether it is correct or not, i would expect an exception message at least, but even this is not generated.

    Do you have got any idea what is wrong in my Umbraco From?

Please Sign in or register to post replies

Write your reply to:

Draft