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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:42:17+00:00 2026-06-09T16:42:17+00:00

PartialView @model OsosYeni23072012.Models.TblMeters <h3> Model.customer_name </h3> <h3> Model.meter_name </h3> Controller [HttpGet] public ActionResult MeterInfoPartial(string

  • 0

PartialView

@model OsosYeni23072012.Models.TblMeters
<h3>
    Model.customer_name
</h3>
<h3>
    Model.meter_name
</h3>

Controller

[HttpGet]
public ActionResult MeterInfoPartial(string meter_id)
{
    int _meter_id = Int32.Parse(meter_id);
    var _meter = entity.TblMeters.Where(x => x.sno == _meter_id).FirstOrDefault();

    return PartialView("MeterInfoPartial", _meter);
}

Razor

@Html.DropDownList("sno", new SelectList(Model, "sno", "meter_name"), "-- Select Meter --", new { id = "meters"})

@Html.Partial("MeterInfoPartial")

I want to load partial view, if dropdownlist change. But I dont know How can I do this. I cant find any example about this. I do this with actionlink. But I did not with dropdown before.

controller parameter meter_id equals dropdownlist selectedvalue.

Thanks.

  • 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-09T16:42:18+00:00Added an answer on June 9, 2026 at 4:42 pm

    You could subscribe to the .change() event of the dropdown and then trigger an AJAX request:

    <script type="text/javascript">
        $(function() {
            $('#meters').change(function() {
                var meterId = $(this).val();
                if (meterId && meterId != '') {
                    $.ajax({
                        url: '@Url.Action("MeterInfoPartial")',
                        type: 'GET',
                        cache: false,
                        data: { meter_id: meterId }
                    }).done(function(result) {
                            $('#container').html(result);
                    });
                }
            });
        });
    </script>
    

    and then you would wrap the partial with a div given an id:

    <div id="container">
        @Html.Partial("MeterInfoPartial")
    </div>
    

    Also why are you parsing in your controller action, leave this to the model binder:

    [HttpGet]
    public ActionResult MeterInfoPartial(int meter_id)
    {
        var meter = entity.TblMeters.FirstOrDefault(x => x.sno == meter_id);
        return PartialView(meter);
    }
    

    Be careful with FirstOrDefault because if it doesn’t find a matching record in your database given the meter_id it will return null and your partial will crash when you attempt to access the model.

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

Sidebar

Related Questions

Suppose you have the following controller action [HttpPost] public ActionResult Save( CustomerModel model )
I have a PartialView strongly typed to a view model <%@ Control Language=C# Inherits=System.Web.Mvc.ViewUserControl<VATRateManager_MVC.Models.ViewModels.RateControlEditViewModel>
I have the following model : public class Foo { [Key] public int FooID
I have a simple model namespace StackOverflow.Models { public class Test { public Test()
This is the model example.cs namespace View_Partial_Editor.Models { public class ExampleView { ... public
CustomerController.cs public ActionResult AddCustomer() { return ContextDependentView(new _Customers()); } public ActionResult EditCustomer(int sno) {
How can you access a PartialView's model, in a View which implements that PartialView?
Here are the codes public class MyModel { [Required] public string Title {get;set;} }
i have the following model method inside my asp.net MVc web application:- public IQueryable<User>
My model looks like this public IEnumerable<SelectListItem> ProductTypes { get; set; } public ProductContent()

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.