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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:10:27+00:00 2026-06-17T00:10:27+00:00

Basically I get a value from a dropdownlist and pass it to a client

  • 0

Basically I get a value from a dropdownlist and pass it to a client method through AJAX. Based on this value, I get data, which I want to put into a textbox.

<script type="text/javascript">        
    $('#dropdownlist').change(function () {
        $.post('/Index/GetJSON/' + this.value, null,                               
            function (data) {
                $('#somefield').val(data)                                  
            });
    });
 </script>

So this method gets called:

[HttpPost]
public JsonResult GetJSON(int ID)
{
    return Json(data);
}

Markup

@Html.EditorFor(m => m.somefield)

somefield does change it’s value visually. But it does not get updated when I inspect it’s value. It’s as if val(data.ID) doesn’t register to the model. Due to my code, I can’t call ModelState.Clear() either…

The reason I use this approach, and not Ajax.Form and partial views, is because I have all the markup inside a HTML.BeginForm (which is submitted) with many different dropdownlists interacting through textboxes through AJAX, and you cannot nest Ajax.Form with HTML.BeginForm. Thus I cannot submit changes to the model through the Ajax.Form and call ModelState.Clear().

  • 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-17T00:10:28+00:00Added an answer on June 17, 2026 at 12:10 am

    .val() sets the value property of an element if you want the change to be reflected in the elements value attr use .attr()

    $('#somefield').attr('value', data)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I want to get the value of a textbox which is to select
Basically I want get data I already have accessed from javascript and passing it
I'm basically trying to pass a GET value from the construct function to the
i bascially want to get the value of a variable from the codebehind to
How can I build an android app which basically get the inputs from user
I have two functions defined that are basically supposed to get a value from
How do I get the value from the IntergerUpDown control? I'am using this :
How can I get the return value of a process? Basically I'm ** ShellExecute
I'm trying to write a very lightweight build script which will basically just get
Hello not sure why Im getting this error. Basically I get it in these

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.