asp.net mvc - Quick question about Ajax.ActionLink and span -


i have simple question.

i have following html code

<a href="#" class="purchase"> <span>purchase</span><em>@string.format("{0:c0}", model.thisitem.itemsaleprice)</em> </a> 

but want use ajax.actionlink make ajax post.

i have following updated code

@ajax.actionlink("purchase", "addtocart", "browse", new { itemid = model.thisitem.itemid }, new ajaxoptions { updatetargetid = "content" }, new { @class = "purchase" }) 

the question how can put tag actionlink?

thank everyone.

updates

i got answer asp.net's forum, , easier. http://forums.asp.net/p/1702210/4518688.aspx/1?p=true&t=634468566867949718

just specify in action link text parameter:

@ajax.actionlink(string.format("{0} {1}", "purchase", string.format("{0:c0}", model.thisitem.itemsaleprice)), "addtocart", "browse", new { itemid = model.thisitem.itemid }, new ajaxoptions { updatetargetid = "content" }, new { @class = "purchase" }) 

edit 1: other overloads not shown, should enough started. if need more details, can take @ mvc3 source , see how setup helpers.

    public static mvchtmlstring customactionlink(this htmlhelper htmlhelper, string linktext, float saleprice, string actionname, string controllername, object routevalues, object htmlattributes)     {         return customactionlink(htmlhelper, linktext, saleprice, actionname, controllername, new routevaluedictionary(routevalues), htmlhelper.anonymousobjecttohtmlattributes(htmlattributes));     }      public static mvchtmlstring customactionlink(this htmlhelper htmlhelper, string linktext, float saleprice, string actionname, string controllername, routevaluedictionary routevalues, idictionary<string, object> htmlattributes)     {         var url = new urlhelper(htmlhelper.viewcontext.requestcontext);          // build <span> tag         var spanbuilder = new tagbuilder("span");         spanbuilder.setinnertext(linktext);         string spanhtml = spanbuilder.tostring(tagrendermode.normal);          // build <em> tag         var embuilder = new tagbuilder("em");         embuilder.setinnertext(string.format("{0:c0}", saleprice));         string emhtml = embuilder.tostring(tagrendermode.normal);          // build <a> tag         var anchorbuilder = new tagbuilder("a");         anchorbuilder.mergeattribute("href", url.action(actionname, controllername, routevalues));         anchorbuilder.innerhtml = spanhtml + emhtml;         string anchorhtml = anchorbuilder.tostring(tagrendermode.normal);          return mvchtmlstring.create(anchorhtml);     } 

note: htmlhelper.anonymousobjecttohtmlattributes under system.web.mvc namespace.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -