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

  • SEARCH
  • Home
  • 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 7663531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:04:44+00:00 2026-05-31T14:04:44+00:00

I have a problem to send my Model into my controller. I use a

  • 0

I have a problem to send my Model into my controller.
I use a button with the ajax to change the page but i need the model who is the first page to the second page.
I would like send my model in my controller but it’s not work.

When i come in the page CreateAll, the renderpartial follow works to display Step1 but if i click on the step2 i would like the mainModel to be send to my controller use a partial view with submodel.

My model is:

public class CreateAllStep
{
    public CreateStep1 Step1 { get; set; }
    public CreateStep2 Step2 { get; set; }
    public CreateAllStep(CreateStep1 step1, CreateStep2 step2)
    {
        this.Step1 = step1;
        this.Step2 = step2;
    }
}

My controller is(when the page start):

public ActionResult Create()
{
    CreateStep1 step1=FillStep1();
    CreateStep2 step2 = FillStep2();
    CreateAllStep allStep = new CreateAllStep(step1, step2);
    return View(allStep);
}

My controller is(when i click on the button, it’s here where i would like send the model):

    [HttpPost]
    public ActionResult Create(String btn, CreateAllStep form)
    {
        if (Request.IsAjaxRequest())
        {
            if (btn != null)
            {
                if (btn == "Step1")
                {
                    return PartialView("Step1",form.Step1);//not work
                }
                else if (btn == "Step2")
                {
                    return PartialView("Step2");//work
                }
                else if(btn =="AllStep")
                {
                    return PartialView("AllStep");
                }
            }
        }
        return View();
    }

And my main view is :

    @model SiteWebEmpty.Models.CreateAllStep
@{
    ViewBag.Title = "Title";
}
<script type="text/javascript">
    $(function () {
        $('form').submit(function () {
            $.post(this.action, $(this).serialize(), function (data) {
                alert(data);
            });
            return false;
        });
    });
</script>

<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>

<h2>Title</h2>
@using (Ajax.BeginForm("Create", //controller action name
"CreateStep", //controller name
new AjaxOptions //ajax options that tell mvc how to perform the replacement
{
    UpdateTargetId = "ViewPage", //id of div to update
    HttpMethod = "Post" //how to call the controller action    
}, new { id = "FormName" }))
{
    @Html.ValidationSummary(true)
    <fieldset>
    <legend>Create </legend>
    <button type="submit" name="btn" value="Step1" id="Step1">Step 1</button>
    <button type="submit" name="btn" value="Step2" id="Step2">Step 2</button>
    <button type="submit" name="btn" value="AllStep" id="AllStep">All Step</button>

    <div id="ViewPage">
    @Html.Partial("Step1", Model)
    </div>        
    </fieldset>    
}

My partial view is:

@model SiteWebEmpty.Models.ArticleRequest.CreateArticle.ArticleRequestDisplayCreateAllStep

<fieldset>
<legend>Step 1</legend>
                @Html.LabelFor(step1 => step1.Step1.Customer)
                @Html.EditorFor(step1 => step1.Step1.Customer)
                @Html.ValidationMessageFor(step1 => step1.Step1.Customer)

                @Html.LabelFor(articleType => articleType.Step1.ArticleType)
                @Html.DropDownList("ArticleType", Model.Step1.ArticleType)
                @Html.ValidationMessageFor(articleType => articleType.Step1.ArticleType)

                @Html.LabelFor(model => model.Step1.LabelType)
                @Html.DropDownList("LabelType", Model.Step1.LabelType)
                @Html.ValidationMessageFor(model => model.Step1.LabelType)
</fieldset>

render html:

<script src="/Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script>
<h2>Title</h2>
<form action="/CreateStep/Create?Length=13" data-ajax="true" data-ajax-method="Post" data-ajax-mode="replace" data-ajax-update="#ViewPage" id="FormName" method="post">    <fieldset>
    <legend>Create </legend>
    <button type="submit" name="btn" value="Step1" id="Step1">Step 1</button>
    <button type="submit" name="btn" value="Step2" id="Step2">Step 2</button>
    <button type="submit" name="btn" value="AllStep" id="AllStep">All Step</button>

    <div id="ViewPage">

<fieldset>
<legend>Step 1</legend>
                <label for="Customer">Customer</label>
                <input class="text-box single-line" data-val="true" data-val-required="Customer is required" id="Customer" name="Customer" type="text" value="" />
                <span class="field-validation-valid" data-valmsg-for="Customer" data-valmsg-replace="true"></span>

                <label for="ArticleType">Article Type</label>
                <select data-val="true" data-val-required="ArticleType is required" id="ArticleType" name="ArticleType"><option value="127">AR1 : New Product</option>
<option value="161">AR2 : Product Modification</option>
</select>
                <span class="field-validation-valid" data-valmsg-for="ArticleType" data-valmsg-replace="true"></span>

                <label for="LabelType">Label Type</label>
                <select data-val="true" data-val-required="LabelType is required" id="LabelType" name="LabelType"><option value="129">Private Label</option>
</select>
                <span class="field-validation-valid" data-valmsg-for="LabelType" data-valmsg-replace="true"></span>
</fieldset>

    </div>        
    </fieldset>    
</form>

Thanks for your help 🙂 !

  • 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-31T14:04:45+00:00Added an answer on May 31, 2026 at 2:04 pm

    Could you post the final HTML?

    I think that your @Html.Partial(“Step1”, Model.Step1) will render a input text with id like Customer or ArticleType instead of Step1.Customer and Step1.ArticleType. What will bind to CreateAllStep.Customer that doesn´t exist.

    If you have the Headers sent by the browsers will help too.

    Update: Change your partial Step1, to accept a CreateAllStep Model and try again

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with Oracle 9.2 and JMS. I created PL/SQL routine to send
I'm a beginner concerning socket programming and I have a problem when I send
I have a problem when trying to send a POST request. The sending method
i have function to send mail with attachment to microsoft exchange server. My problem
I have a bit of a strange problem. I am trying to send in-app
another ordered delivery problem. We have an orchestration which is bound to a send
I use caliburn micro and MEF in wpf and I have this problem. I
I have this problem. I use caliburn micro in WPF. In view I have
I am currently on a Problem. I have an RMI Server with a Model
Not even sure if this is feasible, but here's the use case: I have

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.