I have an issue currently where I am using a Jquery fullcalendar plugin in Asp.Net MVC to display a course details(Course Name, Level, Course Discipline, Start Date, End Date etc..,) based on Month and Date. When loading the View in the browser, the page
is displaying course details based on the Month and year and for the specific date columns. But when i am trying to change the dropdown value i have two dropdowns where I have a Parent dropdown and based on selection of values in the parent dropdown the values
will get populated in the second dropdown. So that is also working fine.
Next step is I'm trying to pass the selected value of the second dropdown through ajax service URL in the on change method of discipline dropdown, the value is getting passed to the controller, but not the same controller which i used while the initial site
load since i was facing an MVC error when i was trying to redirect to the same controller. So i passed the value to a new controller and based on the value i need to pass Json value to the same View again so that the Json value needs to be fed to the events
attribute in the fullcalendar Jquery code as per the selected item to be displayed at runtime during on change of discipline drop down.
Here only i'm facing issue where I have written logic to collect the values and parse as Json, but when i'm trying to pass the Json value to the view i'm not able to pass it as Jsonresult also since it is not redirecting to my view itself. Even i tried using
Actionresult and tried to pass my Json value as session variable so that i can get it in the corresponding view and pass it to the events. But as per my understanding it is not at all hitting the view for the second time from the other controller. Even when
i passed the name of the view also i'm not able to get the value in the on change of drop down. Can anybody kindly suggest how to handle this? Sorry for my lengthy question since i thought to elaborate my issue in detail.
This is the fullcalendar plugin sample which we downloaded and modified based on our requirement -https://fullcalendar.io/
normally your controller action called by ajax, should return Json(), not a view. If the action returns a view, the browser will not display it, the javascript ajax success callback, needs to display the html. see the jQuery .html() method for adding a
html string to the dom.
Here only i'm facing issue where I have written logic to collect the values and parse as Json, but when i'm trying to pass the Json value to the view i'm not able to pass it as Jsonresult also since it is not redirecting to my view itself. Even i tried using
Actionresult and tried to pass my Json value as session variable so that i can get it in the corresponding view and pass it to the events. But as per my understanding it is not at all hitting the view for the second time from the other controller. Even when
i passed the name of the view also i'm not able to get the value in the on change of drop down. Can anybody kindly suggest how to handle this? Sorry for my lengthy question since i thought to elaborate my issue in detail.
You could use a partial view to display the data list, please refer to the following code:
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
None
0 Points
1 Post
Redirecting to view when selected index changed on dropdown in Asp.Net MVC
Oct 16, 2018 02:51 PM|vijayarajanse|LINK
Hello All,
I have an issue currently where I am using a Jquery fullcalendar plugin in Asp.Net MVC to display a course details(Course Name, Level, Course Discipline, Start Date, End Date etc..,) based on Month and Date. When loading the View in the browser, the page is displaying course details based on the Month and year and for the specific date columns. But when i am trying to change the dropdown value i have two dropdowns where I have a Parent dropdown and based on selection of values in the parent dropdown the values will get populated in the second dropdown. So that is also working fine.
Next step is I'm trying to pass the selected value of the second dropdown through ajax service URL in the on change method of discipline dropdown, the value is getting passed to the controller, but not the same controller which i used while the initial site load since i was facing an MVC error when i was trying to redirect to the same controller. So i passed the value to a new controller and based on the value i need to pass Json value to the same View again so that the Json value needs to be fed to the events attribute in the fullcalendar Jquery code as per the selected item to be displayed at runtime during on change of discipline drop down.
Here only i'm facing issue where I have written logic to collect the values and parse as Json, but when i'm trying to pass the Json value to the view i'm not able to pass it as Jsonresult also since it is not redirecting to my view itself. Even i tried using Actionresult and tried to pass my Json value as session variable so that i can get it in the corresponding view and pass it to the events. But as per my understanding it is not at all hitting the view for the second time from the other controller. Even when i passed the name of the view also i'm not able to get the value in the on change of drop down. Can anybody kindly suggest how to handle this? Sorry for my lengthy question since i thought to elaborate my issue in detail.
This is the fullcalendar plugin sample which we downloaded and modified based on our requirement - https://fullcalendar.io/
Updated the code below:
This is the first controller code:
View code:
Second controller code:
Thanks
Vijay
All-Star
58254 Points
15681 Posts
Re: Redirecting to view when selected index changed on dropdown in Asp.Net MVC
Oct 16, 2018 03:19 PM|bruce (sqlwork.com)|LINK
normally your controller action called by ajax, should return Json(), not a view. If the action returns a view, the browser will not display it, the javascript ajax success callback, needs to display the html. see the jQuery .html() method for adding a html string to the dom.
All-Star
45489 Points
7008 Posts
Microsoft
Re: Redirecting to view when selected index changed on dropdown in Asp.Net MVC
Oct 25, 2018 08:13 AM|Zhi Lv - MSFT|LINK
Hi vijayarajanse,
You could use a partial view to display the data list, please refer to the following code:
Code in index view:
Code in controller:
More details, please refer to the following articles:
https://www.c-sharpcorner.com/blogs/drop-down-list-selected-index-changed-event-in-mvc
https://forums.asp.net/t/1542765.aspx?Render+PartialView+according+to+selected+item+in+dropdown+list
Best regards,
Dillion