I'm trying to render a particular section/div click a particular link or button. Suppose link/button is in the A.cshtml
page , and b.cshtml
is a partial view that I want to load in A.cshtml
page within a particular section/div. I tried Ajax.ActionLink
but can't do. Any help or suggestions?
Asked
Active
Viewed 1,040 times
0

matkins
- 1,991
- 1
- 16
- 22

Rakib Jahan Khan
- 1
- 1
3 Answers
1
I tried ajaxactionlink but cant do
That's really not the way to ask a question here. Cant do
is not a precise problem description. Next time when you ask a question on SO show what you have tried.
This being said, let me provide you with an example:
@Ajax.ActionLink("click me", "SomeAction", new AjaxOptions {
UpdateTargetId = "result"
})
<div id="result"></div>
and then you will have an action which will render this partial view:
public ActionResult SomeAction()
{
return PartialView("_NameOfYourPartial");
}
Finally make sure that you have referenced the jquery.unobtrusive-ajax.js
script to your page which uses the HTML5 data-* attributes emitted by the Ajax.ActionLink
helper to hijack the click event and send an AJAX request instead of the normal request:
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>

Darin Dimitrov
- 1,023,142
- 271
- 3,287
- 2,928
0
The controller can return a partial view as action result:
public ActionResult Details()
{
var model = // your model
var viewName = // your partial view name
return PartialView(viewName, model);
}

Dennis Traub
- 50,557
- 7
- 93
- 108
0
Ajax.ActionLink
should do it, may be you missed somwthing.
Check this post it may give you the answer

Community
- 1
- 1

Amir Ismail
- 3,865
- 3
- 20
- 33