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 757093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:19:20+00:00 2026-05-14T15:19:20+00:00

I’m looking at the partialview components of the MVC Framework. i want my partial

  • 0

I’m looking at the partialview components of the MVC Framework.

i want my partial view to be handled in its own action and for the rest of the view to handle itself, but i’m getting an exception because the main page is not getting its view fired.

Am i going around this the wrong way?

My Main View (Jobs/Index.aspx):

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcApplication3.Models.JobViewModel>" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<% Html.RenderPartial("JobListing", Model.Jobs); %> 
</asp:Content>

The partialview (Jobs/JobListing.ascx):

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<MvcApplication3.Models.Job>>" %>

<table>
<tr>
    <td> Job Title  </td>
    <td>   Job Location</td>
</tr>
<%
    foreach (var job in Model)
    {
%>
<tr>
    <td>
        <%= job.Title %>
    </td>
    <td>
        <%= job.Location %>
    </td>
</tr>
<%  
    } 
%>

<% Html.BeginForm("DoSomeStuff", "Job", null, FormMethod.Post); %>

   <%= Html.TextBox("SomeInfo") %>

    <button type="submit" id="submit" />
<% Html.EndForm(); %>

The main controller for both the main view (Index) and the partialview (DoSomeStuff())

    public class JobController : Controller
{
    public ActionResult Index()
    {
        JobProvider provider = new JobProvider(Session);

        JobViewModel vm = new JobViewModel();

        vm.Jobs = provider.GetJobs();

        return View(vm);           
    }

    public PartialViewResult DoSomeStuff()
    {
        return PartialView("JobListing");
    }
}

As you can see in the partial view, it has its own form that posts to the Action called DoSomeStuff(). i want this action to handle any data submitted from that form.
but when the form is submitted the main action (Index) does not fire and then i get an exception as the Model (.Models.JobViewModel) is not passed to the view that the partialview (JobListings) lives in.

basically what im saying is, if i have a myview.aspx with lots of html.RenderPartialView(‘apartialview’) that have forms in them, can i get it so these forms
post to their own actions and the main view (with what ever model it inherits) is handled as well. Rather then having all the form submitting code in the main action for the view.

am i do this wrong?

  • 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-14T15:19:21+00:00Added an answer on May 14, 2026 at 3:19 pm

    I would follow POST-REDIRECT-GET pattern and would define DoSomeStuff like:

    public class JobController : Controller
    {
        [HttpPost]
        public RedirectToRouteResult DoSomeStuff(DoSomeStuffModel model)
        {
            //Do some stuff with model
            return RedirectToAction("Index");
        }
    } 
    

    If you don’t want to reload whole form, you can use jQuery Form Plugin. If you use it, you can stay with PartialViewResult. After posting partial view form, if you specify target option, content of div containing partial view code will be replaced with returned html.

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

Sidebar

Related Questions

I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm interested in microtypography issues on the web. I want a tool to fix:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to show the soap response to UIWebview.. my soap response is, <p><img
I'm trying to select an H1 element which is the second-child in its group

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.