asp.net - ASP MVC passing form data with ActionLink -
i able pass data text box on page tan action using actionlink.
i specify actionlink follows in view
@ajax.actionlink( "utc", "gettime", { zone="bst" }, new ajaxoptions { insertionmode = insertionmode.replace, updatetargetid = "targetelementid", onbegin = "gettime_onbegin", } )
since cannot see way specify in helper thought implement onbegin event , there. noted onbegin receives xmlhttprequest, containing details of request performed , object, whos purpose escapes me, contains url property object.url object.context.url, thought add property need pass action url, thinking resolve same-named parameter of action.
function gettime_onbegin(xmlhttprequest, object) { object.context.url = object.context.url + "&text=" + $('textboxid').val(); }
my controller action
public string gettime(string zone, string text) { datetime time = datetime.utcnow; return string.format( "{0:h:mm:ss tt}({1},{2})", time, zone.toupper(),text); }
however text not being passed , null.
is there more elegant way ?
Comments
Post a Comment