More in this section

Forums / Developing with Sitefinity / Adding MVC Form Widget to Master Page With Form

Adding MVC Form Widget to Master Page With Form

2 posts, 0 answered
  1. Mac
    Mac avatar
    1 posts
    10 Apr 2014
    20 Aug 2014
    Link to this post


    I have been developing an MVC form widget to use on a pre-existing ASP.NET web forms application. The master page has a form. When I add the form widget to the home page, publish the page, and then fill-in the widget form with data and hit the submit button, I get the following javascript error:

      Cannot set property 'action' of undefined

    The error occurs in this code block (which must be javascript added by Sitefinity). Error occurs at statement in bold:

    <script type="text/javascript">
                function handleFormSubmitElements(elementName) {
                    var allSubmitElements = document.getElementById("quoteForm").getElementsByTagName(elementName);
                    var elementCount = allSubmitElements.length;
                    while(elementCount) {
                        typeAttr = allSubmitElements[elementCount - 1].getAttribute("type");
                        if(typeAttr == "submit") {
                            allSubmitElements[elementCount - 1].onclick = function() {
                            document.forms["aspnetForm"].action = "/mvc-page-home-test/Index";
                                document.forms["aspnetForm"].method = "POST";


    Can I not create a form widget that will work in a web forms application that already has a form? Can someone help me out here?

    Thanks so much,


  2. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    19 Apr 2017
    25 Aug 2014
    Link to this post
    Hello Mac,

    The problem comes from the default server form Id. The MVC widget expects that its ID is aspnetForm and tries to find it. However, probably the form on your master page/ template is with different Id. Please, ensure the main form is with the same Id. For reference, here is a default markup of a Frontend master page:
    <%@ Page AutoEventWireup="true" Language="C#" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <head runat="server">
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale = 1.0" />
        <form id="aspnetForm" runat="server">
            <div class="sfPublicWrapper" id="PublicWrapper" runat="server">
                <sf:SitefinityPlaceHolder ID="Body" runat="server"></sf:SitefinityPlaceHolder>

    This is why aspnetForm is hard coded in the injected script reference.

    Nikola Zagorchev
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
2 posts, 0 answered