Reputation: 3
I have a querystring like this:
http://localhost:2563/Skill?Months=1,2,3,4,5,6,7,8,9,10,11,12&SelectedMonth=8&Year=2016,2017,2018&SelectedYear=2016&....
And I want to pass Months, SelectedMonth, Year, SelectedYear value into Index() of controller (Index is a function takes 0 argument). And another issue, after Index function completed, I want binding function (in javascript) to run to bind value into dropdownlist by the SelectedMonth, SelectedYear in querystring
Please help. This function helps access the Views by QueryString (not through my website) Many thanks.
Upvotes: 0
Views: 958
Reputation: 2032
First, the action name is wrong. you should use the following,
instead of
second, You need to pass some parameters. Here is how:
public ActionResult Index(List<int> Months,int SelectedMonth,List<int> Year, int Year)
{
}
remember to pass values as you wish to work with them. if you don't, you will face some error. use try catch block to prevent and handle exceptions.
You may also face exception accessing the web page. try to put optional parameter instead of using the above one.
public ActionResult Index(List<int>? Months,int? SelectedMonth,List<int>? Year, int? Year)
{
}
Upvotes: 1
Reputation: 730
You need to get parameters from here HttpContext.Current.Request.QueryString
Upvotes: 0
Reputation: 440
public ActionResult Index(List<int> Months,int SelectedMonth,List<int> Year, int Year)
{
}
or use Reqest.QueryString
public ActionResult Index()
{
var months=Reqest.QueryString["Months"];
.
.
.
}
Upvotes: 0