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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:08:27+00:00 2026-06-18T09:08:27+00:00

I’m learning ASP.NET MVC 2 and ran into a slight issue which I can’t

  • 0

I’m learning ASP.NET MVC 2 and ran into a slight issue which I can’t seem to figure out.

Basically I have a drop down which is populated from an Access db and when the user selects a value I would like to call an ActionResult passing through the selected value as a parameter, I’m trying to achieve this by using $.post

The drop down is getting populated with data and I can confirm that the javascript function fires but the break point in my ActionResult is still not being hit, I’d appreciate any advice:

Model:

public class SuppliersModel
{
    public SuppliersModel()
    {
    }

    public SuppliersModel(string id)
    {
    }

    private string id;
    public string ID
    {
        get { return id; }
        set { id = value; }
    }

    public SelectList OurSuppliers
    {
        get 
        {
            List<SelectListItem> suppliers = GetSuppliers();
            var list = new SelectList(suppliers, "Value", "Text");
            return list;
        }
    }

    public IEnumerable<string> UniqueSuppliers{get;set;}

    private List<SelectListItem> GetSuppliers()
    {
        var suppliers = new List<SelectListItem>();
        string conn = WebConfigurationManager.ConnectionStrings["connection"].ConnectionString;

        using (var connection = new OleDbConnection(conn))
        {
            connection.Open();
            string commandText = "SELECT [Supplier], [ID] FROM [Suppliers] ORDER BY [Supplier]";
            using (var command = new OleDbCommand(commandText, connection))
            {
                command.CommandType = System.Data.CommandType.Text;
                using (OleDbDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string id = reader["ID"].ToString();
                        string supplier = reader["Supplier"].ToString();
                        suppliers.Add(new SelectListItem() { Text = supplier, Value = id });
                    }
                }
            }
            connection.Close();
            return suppliers;
        }
    }
}

Controller:

public class SuppliersController : Controller
{
    public ActionResult Suppliers()
    {
        SuppliersModel model = new SuppliersModel();
        return View(model);
    }

    [HttpPost]
    public ActionResult SuppliersById(string id)
    {
        System.Diagnostics.Debugger.Break();
        SuppliersModel model = new SuppliersModel(id);
        return View(model);
    }
}

View:

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
        $(function () {
            $('#suppliers').change(function () {
                debugger;
                $.post('@Url.Action("SuppliersById", "Suppliers")', { id: $(this).val() }, 
                function (result) {
                });
            });
        });
    </script>
    <h2>
        Suppliers</h2>
    <div>
        <%= Html.DropDownList("suppliers",Model.OurSuppliers) %>
    </div>
    <% if (Model.ID != null)
       { %>
    <table>
        <tr>
            <th>
                <h2>
                List of suppliers
                </h2>
            </th>
        </tr>
        <% foreach (var item in Model.UniqueSuppliers)
           { %>
        <tr>
            <td>
                <%: Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) %>
                |
                <%: Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ })%>
                |
                <%: Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })%>
            </td>
        </tr>
        <% } %>
    </table>
    <% } %>
</asp:Content>
  • 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-18T09:08:28+00:00Added an answer on June 18, 2026 at 9:08 am

    There was a syntax error in my javascript function, this fixed it:

    <script type="text/javascript">
        $(function () {
            $('#suppliers').change(function () {
                $.post('<%=Url.Action("SuppliersById", "Suppliers")%>', { id: $(this).val() }, 
                function (result) {
                });
            });
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from

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.