Tuesday, 20 August 2013

pass value from dropdown to html actionlink mvc4 razor

pass value from dropdown to html actionlink mvc4 razor

I am trying to pass a value from a drop down list to an existing link,
however nothing seems to work:
index.cshtml:
@Html.ActionLink("Download", "MyDownload", null, new { @class = "button"
})  
@Html.DropDownList("schools", "-- All Schools --")  
in my SchoolsController:
public FileContentResult MyDownload(string school="")
{
List1<>
List2<>
var vals =
from list1
join list2
from
select new {
};
if(school ! ="")
{
vals.where(x.list2.schools==school).tolist(); **// I get this
error: "Object reference not set to an instance of an object."**
}
}
Something I can do easily in other languages, I find learning C# MVC takes
forever.

No comments:

Post a Comment