Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
How to pass JsonResult to view in asp.net mvc

I have a business model class that have put some value then business model class to pass in model class properties.Now I want to pass the value in view page. But I can't use Viewbag because its required a collection.That why I can't pass value in view page.

Is it possible to pass value in view page??

If possible. how to pass it?

    public async Task<JsonResult> GetDeptName(int studentId)
    {
        var model = _scope.Resolve<FormModel>();

        if (ModelState.IsValid)
        {
            await model.DeptList(studentId);
        }

        return Json(new {model.DeptId, model.DeptName });
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can pass concrete objects just like this to the View() as a parameter:

public ActionResult YourMethod()
{
    model = new YourModelObject
    {
        // Fill your properties here
    };

    return View(model);
}

In the page.cshtml you can set the model like this:

@model YourModelObject

And use like this:

@Html.LabelFor(x => x.YourProperty)
@Html.EditorFor(x => x.YourPropery)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!