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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:06:50+00:00 2026-06-10T22:06:50+00:00

i am trying to pass in my model to a partial view. When it

  • 0

i am trying to pass in my model to a partial view. When it is passed in I would like to set the value of the argument. When I run this i get:

Object reference not set to an instance of the object

How can it say that because I passed in this Model?

@using passTextbox.Models
@model passTextbox.Models.MyViewModel

@Html.TextBoxFor(t=>t.someobject)

@{ Html.RenderAction("test", new MyViewModel() { someobject = "$('#somevalue')" });}

 public class MyViewModel
 {
        public string someobject { get; set; }
 }

partialview:

@model passTextbox.Models.MyViewModel
<h2>test</h2>
<script src="../../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var tb = @Model.somevalue;
        tb.val("new value");
    });
</script>
  • 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-10T22:06:52+00:00Added an answer on June 10, 2026 at 10:06 pm

    Try to use Html.RenderPartial instad of Html.RenderAction

    public class MyViewModel
        {
            public string someObject { get; set; }
        }
    

    In the View

    @{Html.RenderPartial("partial", new MvcApplication1.Controllers.MyViewModel() { someObject = "test" });}
    

    and finally in the Partial view

     @model MyViewModel
    
    <h2>test</h2>
    <script type="text/javascript">
        $(document).ready(function () {
            var tb ="@Model.someObject";
            alert(tb);
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pass in an array to this dropdownlist in my Partial View:
I am getting this error when trying to pass my object to the view.
I'm trying to pass model attributes to javascript through html like this: <script type=text/javascript>
I am trying pass class as value in hashmap. I need to get the
I'm using MVC3 razor, and I'm trying to pass an object to a partial
I'm trying to get a nested model to bind correctly with a nested view
I'm trying to pass a model attribute to a view, after successfully setting it
I am trying to pass an object of model class for edit but receing
I'm trying to pass a ViewModel property to a partial view, but getting the
I'm using ASP.NET MVC and would like to get Model information for use within

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.