Link to home
Start Free TrialLog in
Avatar of Steve7423
Steve7423Flag for Canada

asked on

How to display controls in a view based on the onSelectedChange event of a dropdown

I’m building an intranet site that is driven based on projects.  The user selects a project from a dropdown and then all other data the user views is based on the specific project selected from the dropdown.

Charts and graphs will display once the user selects the item.  The charts and graphs will then need to be driven using the value selected from the dropdown.  I suspect this may require jquery which I’m not familiar with so any beginner links regarding Jquery would be helpful.

The problems I need to solve are:

1) How to fire an event for the dropdown in the view

2) How to display charts to the view using the dropdown event

I’ve not done this before and the typical hide and show properties may not be viable.  

3) Is it possible to load empty chartds and graphs and then populate them from the dropdown event?

I need step by step instructions on how to do this as I’ve not done this before.  Your guidance is greatly appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Easwaran Paramasivam
Easwaran Paramasivam
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steve7423

ASKER

Can't seem to get this to work.  The selectedInddexChanged event is not firing.  What am I doing wrong ??  When I change the value in the dropdown shouldn't the DropDownList_SelectedIndexChanged event in the controller fire??  

The view:


<h4>
    @Html.DropDownList("Project_ID", (IEnumerable<SelectListItem>)ViewData["Project_Number"],
    new { style = "width: 150px; font-size: .5em" })

    <div>
        <asp:DropDownList ID="DropDownList" runat="server" autopostback="True" OnSelectedIndexChanged="DropDownList_SelectedIndexChanged"></asp:DropDownList>
    </div>
</h4>


The Controller:

protected void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            // capture the project number and name from the dropdown on the view and   assign it to a new instance of the User_Selected_Project Property

            Global_Properties property = new Global_Properties();
            DropDownList dropDown = new DropDownList();
            property.User_Project_Selected = dropDown.SelectedItem.ToString();
           
            //display the view with the charts which are driven by the above property.  Each chart uses a Link statement with a project number parameter.

        }
EaswaranP:  I need a hand.  I'm very new to mvc, java and the like.  i have no idea what I'm doing and need some guidance.

I've created an actionresult in my controller to do something as I posted above.
Now my problem is understanding the Java part of the view to call that actionresult in the controller, then within the view display some charts.  right now I just need to figure out how to call the action in the controller from the view.  I've tried the example provided in http://asp-net-example.blogspot.in/2009/03/how-to-use-dropdownlist.html
but I don't get what's going on.

I tried this but it errors out in a runtime error:

 <!DOCTYPE html>
<script type="text/javascript">
  $(function(){
  $("#Project_ID").change(function(){
     $.get("@Url.Action("ProjCBOItemSelected","Home")",function(){
         //display charts
     });
  });
});
</script>

I replaced the DropDownList_SelectedIndexChanged() with:

public ActionResult ProjCBOItemSelected()
{
}


what am I doing wrong obviously I'm missing some thing perhaps syntax