I am new to MVC and need help in it. I have a main view (index.vbhtml) and this page is rendered successfully. I have a partial view (test.vbhtml) and this partial view is added to the index.vbhtml dynamically using jquery get method on occurring of an event.
$.get('@Url.Action("test", "abc")', function (data) {
$('#partialViewRender').html(data);
});
I am able to render this partial view successfully. I am adding partial view in this way because i have multiple partial views which will be rendered in similar fashion, like on occurrence of an event. all these partial views will be rendered in a same tag, partialViewRender, only one at a time.
inside these partial views, i need to form post occurs. Like clicking submit button on test partial view, form post occurs and post controller action is called. inside the action method, on the basis of selected value of drop down relevant data is fetched and need to be displayed to the user. this is the point where i am stuck. I don't want my main view to be redirected, i want same main view with partial view rendered with updated data. In other words i want to achieve similar behavior as we have in classic asp applications on code behind event.
i have tried both html submit button and Ajax.ActionLink for this purpose. but both of them redirects to the partialview url. i.e. localhost/test inside action method i have tried return with PartialView, View, RedirectToAction, Json but no success. all of them redirects to a new url.
here is the code from controller
<HttpGet>
Function test() As ActionResult 'this is called on jquery get method
'do some intializing data stuff
Return PartialView("test")
End Function
<HttpPost>
Function test(id As String) As ActionResult
'fetch data on basis of id, this data needs to be shown in a grid
End Function
any help will be a great deed. I am totally stuck here.