MVC RAZOR anyone has a working Ajax image html helper working

  1. #1

    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

    
    @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 href
    however 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 7:10 AM.
  2. #2
    Hi,

    Personally, I don't know the answer. Unfortunately.

    Generally, your question is not related to Ext.NET. So, it would be best to ask this question on some specialized Microsoft MVC forums or, maybe, stackoverflow.
  3. #3

    RE Ext.Net

    Quote Originally Posted by Daniil View Post
    Hi,

    Personally, I don't know the answer. Unfortunately.

    Generally, your question is not related to Ext.NET. So, it would be best to ask this question on some specialized Microsoft MVC forums or, maybe, stackoverflow.
    I am new .NET , MVC but been programming for many years in ASP, VB and some PHP

    I am writing this RAZOR C# app. in .NET Framework, what made me understood when I found this forum Ext.Net here, you are referring to the extensions and html or other helpers you can write for a MVC or most likely any other .net application

    One of your visitors will write hopefully a follow up or I will update this thread when I learn how to properly link a GET request via Ajax with an image href
  4. #4
    Quote Originally Posted by repsak View Post
    One of your visitors will write hopefully a follow up or I will update this thread when I learn how to properly link a GET request via Ajax with an image href
    Yes, it would be great.

Similar Threads

  1. MVC3 Razor: Desktop button is not working
    By nahuel2203 in forum 2.x Help
    Replies: 0
    Last Post: Jun 24, 2012, 4:02 AM
  2. [CLOSED] DropTarget Not working in razor syntax
    By machinableed in forum 2.x Premium Help
    Replies: 3
    Last Post: Apr 30, 2012, 12:08 PM
  3. Javascript intellisense in Razor not working
    By mpritchard in forum 2.x Help
    Replies: 0
    Last Post: Apr 19, 2012, 10:05 AM
  4. vbox layout is not working on image button
    By robertgan in forum 1.x Help
    Replies: 1
    Last Post: Feb 27, 2012, 10:17 AM
  5. Ajax Event not working
    By vickygajula in forum 1.x Help
    Replies: 3
    Last Post: Dec 09, 2010, 6:19 PM

Posting Permissions