Feb 20, 2012, 6:08 AM
MVC RAZOR anyone has a working Ajax image html helper working
I have three different kind of ajax image html helpers however with every one I have problems to hit the div target .. on the same page I have multiple ajax text links and there is no problem with the same action controller and same partial view etc ...
I have no issue with the following ajax text link it behaves as expected
however it ends up we have links like
http://localhost:55647/new__read_xyz...dNew?Length=14
i
none of the image ajax helper hit the target div's all open up _top
I tested the same PartialView's with the ajax text link successfully
can somebody please show me a working example with ajax image link what hits a div
I have no issue with the following ajax text link it behaves as expected
@Ajax.ActionLink("Add New", "AddNew", new { controller= "NewParticipant" }, new AjaxOptions
{
UpdateTargetId = "customBenefic",
InsertionMode = InsertionMode.Replace,
HttpMethod = "GET",
LoadingElementId = "progress"
})
I would like to achieve the same as above with an image and a hrefhowever it ends up we have links like
http://localhost:55647/new__read_xyz...dNew?Length=14
i
public static MvcHtmlString ActionImageLink(this HtmlHelper helper, string imageUrl, string altText, string actionName,
string controller, object routeValues)
{
var builder = new TagBuilder("img");
builder.MergeAttribute("src", imageUrl);
builder.MergeAttribute("alt", altText);
var link = helper.ActionLink("[replaceme]", actionName, controller, routeValues);
return new MvcHtmlString(link.ToHtmlString().Replace("[replaceme]", builder.ToString
(TagRenderMode.SelfClosing)));
}
public static MvcHtmlString AjaxActionImageLink(this HtmlHelper helper, string imageUrl, string altText, string
actionName, string controller, object routeValues)
{
var builder = new TagBuilder("img");
builder.MergeAttribute("src", imageUrl);
builder.MergeAttribute("alt", altText);
builder.MergeAttribute("title", altText);
var link = helper.ActionLink("[replaceme]", actionName, controller, routeValues);
return new MvcHtmlString(link.ToHtmlString().Replace("[replaceme]", builder.ToString
(TagRenderMode.SelfClosing)));
}
none of the image ajax helper hit the target div's all open up _top
@Html.AjaxActionImageLink("../../Images/add_new_c_1.png", "New Participant", "AddNew", "NewParticipant", new
AjaxOptions
{
UpdateTargetId ="customBenefic",
InsertionMode = InsertionMode.Replace,
HttpMethod = "GET",
LoadingElementId = "progress"
})
I tested the same PartialView's with the ajax text link successfully
can somebody please show me a working example with ajax image link what hits a div
Last edited by repsak; Feb 20, 2012 at 6:10 AM.