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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:07:50+00:00 2026-05-15T22:07:50+00:00

Controller action: public ActionResult Index() { ViewData[sample] = DateTime.Now.ToLongTimeString(); Thread.Sleep(3000); return View(); } View

  • 0

Controller action:

    public ActionResult Index()
    {

        ViewData["sample"] = DateTime.Now.ToLongTimeString();
        Thread.Sleep(3000);
        return View();
    }

View page:

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2>Index</h2>

<div id="divId"><%= Html.Encode(ViewData["sample"])%></div>

 <script type="text/javascript">var event = new Object(); $get("panelOneForm").onsubmit();</script>
 <%using (Ajax.BeginForm("Index", "Proba", new AjaxOptions() { UpdateTargetId = "divId" }, new { id = "panelOneForm" })) { } %>

</asp:Content>

I try to make auto update View but failed. What is 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-15T22:07:51+00:00Added an answer on May 15, 2026 at 10:07 pm

    You could define an invisible submit button inside the form:

    <div id="divId"></div>
    
    <%using (Ajax.BeginForm("Index", "Proba", new AjaxOptions() { UpdateTargetId = "divId" })) { %>
        <input type="submit" id="btnSubmit" style="display:none;" />
    <% } %>
    
    <script type="text/javascript">
        // Make sure you put this script after the form
        // so that the button is loaded into the DOM before
        // manipulating it
        $get("btnSubmit").click();
    </script>
    

    Also the Index action on the Proba controller that you are invoking asynchronously needs to return only a partial view or directly some content. Notice that ViewData is no longer used neither in the controller action nor in the resulting div:

    public ActionResult Index()
    {
        // You probably want to remove the next line before shipping your
        // application in production as it is not good to stall the thread for 3s
        Thread.Sleep(3000);
        return Content(DateTime.Now.ToLongTimeString(), "text/plain");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 492k
  • Answers 492k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The problem was solved by closing the corresponding cursor after… May 16, 2026 at 10:22 am
  • Editorial Team
    Editorial Team added an answer Yes. You can do this with a bit of a… May 16, 2026 at 10:22 am
  • Editorial Team
    Editorial Team added an answer This is a textbook example of a directed graph. You… May 16, 2026 at 10:22 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I want to show the content of ViewData, which holds string in my case,
I'm doing some simple MS unit tests on my standard, nothing special controller. When
In my ASP.net MVC View I have a dropdown that I want to get
I'm learning ASP.NET MVC and bugged by one issue. In the HomeController, the Index
I don't think this should be in my view, but instead handled by the
I would like to define following attribute on MVC2: public class BackAttribute : ActionFilterAttribute
I have this little bit of code: using System; using System.Web.Mvc; public class SecureFilter
The routing I need is quite simple, I must be missing something there. As
I'm building an ActionFilter to reuse some code for a simple spam block -
So i'm doing a wizard as such located here: how to make a wizard

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.