Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6050837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:44:05+00:00 2026-05-23T07:44:05+00:00

System I working on is CMS where you insert templates like Contact form template

  • 0

System I working on is CMS where you insert templates like Contact form template and save that to database. This template is coded against server side to process data.

Now my “contentDiv” within form where all the templates were insert and saved than showed on the page withint form tag wrapped like

@using (Html.BeginForm("Edit", "Home", FormMethod.Post, new { id = "first" }))
{
    @Html.Hidden("someId", @Model.PageId)

}

<div id="contentDiv"  style="width:100%">@Html.Raw(Model.Html)</div>

Above form is than saved as

$(function () {
    $("form#first").submit(function (e) {
        e.preventDefault();

        var viewmodel = {
            Id: $("#someId").val(),
            Html: $("#contentDiv").val()
        };

        $.ajax({
            url: $(this).attr("action"),
            type: "POST",
            data: JSON.stringify(viewmodel),
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            beforeSend: function () { $("#status").fadeIn(); },
            complete: function () { $("#status").fadeOut(); },
            success: function (data) {
                var message = data.Message;

            },
            error: function () {

            }
        });
    });
});

notice that I moved “contentDiv out of form tag as my contact form which is wrapped in a form tag can not be nested within id=first form.

Is there a solution to form nesting? . If not than

My another question is

contentDiv is not wrapped up in form tag that means if client browser has javascript disabled than he wont be able to post contentDiv data to server and form will be of no use.

What to do?

If I don’t move contentDiv out of form tag than than after inserting template the structure will be nesting of forms

@using (Html.BeginForm("Edit", "Home", FormMethod.Post, new { id = "first" }))
    {
<form id="contactform" action="/Home/Email"  method="post" >                
    <div class="clear" style="padding-bottom:10px;"></div>

    <div class="formCaption">Full Name</div>
    <div class="formField"><input id="fullName" name="fullName" class="standardField" /></div>




    <div><input id="sendBtn" value="Send" type="button" /></div>
</form> 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:44:06+00:00Added an answer on May 23, 2026 at 7:44 am

    I didn’t understand from your description why the html needs to be outside the form. Also you should not use the .val() method for divs. You should use .html():

    var viewmodel = {
        Id: $("#someId").val(),
        Html: $("#contentDiv").html()
    };
    

    Of course because you are using javascript to fetch the html which is outside of the main form if client browser has javascript disabled the form will be of no use. Only if you move the html inside the main form would this work without javascript:

    @using (Html.BeginForm("Edit", "Home", FormMethod.Post, new { id = "first" }))
    {
        @Html.HiddenFor(x => x.PageId)
        @Html.HiddenFor(x => x.Html)
        <input type="submit" value="Edit" />
    }
    
    <!-- 
    You could still keep the div for preview or something but don't make 
    any use of it when submitting.
    -->
    <div id="contentDiv" style="width:100%">
        @Html.Raw(Model.Html)
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a CMS system that receives urls like this: /parent1/parent2/child/ Now it's
I am working with system like CMS that need to versioning documents. what is
I am working with a CMS like system, phpBMS, which defines a certain way
I am working within the confines of a php based CMS like system, which
I'm working on a simple custom cms - this is for a school that
I'm using PHP 4.3.9, Apache/2.0.52 I'm trying to get a login system working that
I'm working on a large c++ system that is has been in development for
I am working with a CMS system, and using a kind of smartform am
I am working on a CMS project using ASP.Net 3.5/Visual studio 2008.This is the
I am working in the confines of a CMS system, which defines certain fields

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.