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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:16:57+00:00 2026-06-15T12:16:57+00:00

I’m writing a tabbed page websystem in ASP.NET MVC3 and when I use ajax.BeginForm.

  • 0

I’m writing a tabbed page websystem in ASP.NET MVC3 and when I use ajax.BeginForm. The partial view isn’t used to update the div but is show as a page.

What is wrong with the code? And why isn’t it working? Thanks for the help!

I’m to figuring it out but can’t get my head around it. Here is my code:

Controller:

public ActionResult Index(int id)
    {
        var shareholder = db.shareholder.Include("company").Include("groups");
        return PartialView("Index", shareholder.ToList());
    }

    //
    // GET: /Shareholder/Create

    public PartialViewResult Create()
    {
        ViewBag.company_id = new SelectList(db.company, "id", "name");
        ViewBag.groups_id = new SelectList(db.groups, "id", "name");
        return PartialView("Create");
    }

    //
    // POST: /Shareholder/Create

    [HttpPost]
    public ActionResult Create(shareholder shareholder)
    {
        if (ModelState.IsValid)
        {
            db.shareholder.AddObject(shareholder);
            db.SaveChanges();
            return RedirectToAction("Index", new { id = shareholder.company_id });
        }

        ViewBag.company_id = new SelectList(db.company, "id", "name", shareholder.company_id);
        ViewBag.groups_id = new SelectList(db.groups, "id", "name", shareholder.groups_id);
        return PartialView("Create", shareholder);
    }

partial View:

    <script src="<%: Url.Content("~/Scripts/jquery.validate.min.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js") %>"
    type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/MicrosoftAjax.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/MicrosoftMvcValidation.js") %>" type="text/javascript"></script>
<% using (Ajax.BeginForm("Create", "Shareholder", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "tabs-2", InsertionMode = InsertionMode.Replace }))
   { %>
<%: Html.ValidationSummary(true) %>
<fieldset>
    <legend>shareholder</legend>
    <div class="editor-label">
        <%: Html.LabelFor(model => model.company_id, "company") %>
    </div>
    <div class="editor-field">
        <%: Html.DropDownList("company_id", String.Empty) %>
        <%: Html.ValidationMessageFor(model => model.company_id) %>
    </div>
    <div class="editor-label">
        <%: Html.LabelFor(model => model.name) %>
    </div>
    <div class="editor-field">
        <%: Html.EditorFor(model => model.name) %>
        <%: Html.ValidationMessageFor(model => model.name) %>
    </div>
    <p>
        <input type="submit" value="Create" />
    </p>
</fieldset>
<% } %>
<div>
    <%: Html.ActionLink("Back to List", "Index") %>
</div>

The view that is calling the partial view:

<script src="<%: Url.Content("~/Scripts/jquery.validate.min.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js") %>"
    type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/MicrosoftAjax.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/MicrosoftMvcValidation.js") %>" type="text/javascript"></script>
<script type="text/javascript">
    var count = 2;
    $(document).ready(function() {
        $("#tabs").tabs();
        getContentTab (1, "/Company/Details/<%=Model.id %>");
    });

    function getContentTab(index, url) {
        $.ajax({
            url: url,
            success: function(result) {  
                for (var i = 0; i <= count; i++) {
                    document.getElementById("tabs-" + index).style.display = 'none';                     
                }
                $("#tabs-" + index).html(result);
                document.getElementById("tabs-" + index).style.display = 'block';
                $.validator.unobtrusive.parse("form"); 
            },
            error: function (xhr, status, error) {
                alert(error);
            },
        });
    }
</script>
<h2>
    <%=Model.name %></h2>
<div id="tabs">
    <ul>
        <li><a href="#tabs-1" onclick="getContentTab(1, '/Company/Details/<%=Model.id %>');">
            <%= VOWWebsite.Resource.Details%></a></li>
        <li><a href="#tabs-2" onclick="getContentTab(2, '/Shareholder/Index/<%=Model.id %>');">
            <%= VOWWebsite.Resource.Shareholders%></a></li>
    </ul>
    <div id="tabs-1">
    </div>
    <div id="tabs-2">
    </div>
</div>
  • 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-06-15T12:16:58+00:00Added an answer on June 15, 2026 at 12:16 pm

    You have to include jquery.unobtrusive-ajax.min.js in your page:

    <script src="<%: Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js") %>"
    type="text/javascript"></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I am writing an app with both english and french support. The app requests

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.