When i click on Ajax.ActionLink updated information open in a
new window(patitial view). But itmust be addedon the same page. How solve this problem? Please, help
I addedthe following codeto the view
Index
<div id="dailydeal">
@Ajax.ActionLink("Нажмите здесь, чтобы узнать телефон дня!",
"DailyDeal",
new AjaxOptions {
UpdateTargetId="dailydeal",
InsertionMode=InsertionMode.Replace,
HttpMethod="GET"})
</div>
In controller Shop cretae method DailyDeal():
private Make GetDailyDeal()
{
return db.Make.OrderBy(a=> a.Price).First();
}
public ActionResult DailyDeal()
{
var make = GetDailyDeal();
return PartialView("DailyDeal", make);
}
Probably there is an error in some javascript function that prevents the correct working of the javascript unobtrusive ajax. Enable the debug in your browser so it will seignal you any javascript error.
I case of syntax errors you should be able to see it also in the warnings window of visual studio
DimiBy
Member
187 Points
233 Posts
Not work Ajax.ActionLink
Apr 01, 2012 10:45 AM|LINK
Hello, People
When i click on Ajax.ActionLink updated information open in a new window(patitial view). But it must be added on the same page. How solve this problem? Please, help
I added the following code to the view Index
<div id="dailydeal"> @Ajax.ActionLink("Нажмите здесь, чтобы узнать телефон дня!", "DailyDeal", new AjaxOptions { UpdateTargetId="dailydeal", InsertionMode=InsertionMode.Replace, HttpMethod="GET"}) </div>In controller Shop cretae method DailyDeal():
private Make GetDailyDeal() { return db.Make.OrderBy(a=> a.Price).First(); } public ActionResult DailyDeal() { var make = GetDailyDeal(); return PartialView("DailyDeal", make); }And create partitial view DailyDeal:
@model ShopRusWizards.Models.Make <p> <img class="img_index" alt="@Model.Name", src="@Url.RouteUrl(new { filename = Model.UrlMake })" /> </p> <p> @Model.Name </p> <p> @String.Format("0:F", Model.Price) </p>francesco ab...
All-Star
20910 Points
3278 Posts
Re: Not work Ajax.ActionLink
Apr 01, 2012 12:50 PM|LINK
probably you forgot to add a reference to the unobtrusiveajax js file, that handle ajax links and ajax forms on th client side.
Mvc Controls Toolkit | Data Moving Plug-in Videos
DimiBy
Member
187 Points
233 Posts
Re: Not work Ajax.ActionLink
Apr 01, 2012 01:03 PM|LINK
i added:
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive - ajax.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
francesco ab...
All-Star
20910 Points
3278 Posts
Re: Not work Ajax.ActionLink
Apr 01, 2012 01:11 PM|LINK
Are you sure ajax is enabled in your we.config?:
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
Moreover the - in your unobtrusive-ajax appears to have a blank both to its left and to its right, pls verify, and in the case remove the blanks.
Mvc Controls Toolkit | Data Moving Plug-in Videos
DimiBy
Member
187 Points
233 Posts
Re: Not work Ajax.ActionLink
Apr 01, 2012 01:18 PM|LINK
yes, i have:
<appSettings>
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
francesco ab...
All-Star
20910 Points
3278 Posts
Re: Not work Ajax.ActionLink
Apr 01, 2012 01:19 PM|LINK
and the spaces to the left and right of - ?
Mvc Controls Toolkit | Data Moving Plug-in Videos
DimiBy
Member
187 Points
233 Posts
Re: Not work Ajax.ActionLink
Apr 01, 2012 01:53 PM|LINK
yes, too
DimiBy
Member
187 Points
233 Posts
Re: Not work Ajax.ActionLink
Apr 01, 2012 02:12 PM|LINK
i checked method DailyDeal() with Request.IsAjaxRequest() and
does not fall into if(Request.IsAjaxRequest()). That is, does not work asynchronously. The question now is, why?
francesco ab...
All-Star
20910 Points
3278 Posts
Re: Not work Ajax.ActionLink
Apr 01, 2012 02:29 PM|LINK
Probably there is an error in some javascript function that prevents the correct working of the javascript unobtrusive ajax. Enable the debug in your browser so it will seignal you any javascript error.
I case of syntax errors you should be able to see it also in the warnings window of visual studio
Mvc Controls Toolkit | Data Moving Plug-in Videos
DimiBy
Member
187 Points
233 Posts
Re: Not work Ajax.ActionLink
Apr 01, 2012 02:47 PM|LINK
and how debug in Firefox?