c# - html actionLink parameters to view -
i'm noob in .net , web developpement :s i'm having issue using html.beginform , html.actionlink. got in homeweb.cshtml:
@using (html.beginform("resultweb", "result", new { val = 1 }, formmethod.post )) { <div class="main-block"> <input style="width:100%;" type="text" name="searchvalue" /><br /> <div style="text-align: center;"> <input type="submit" value="submit" /> </div> </div> } its calling result controller , resultweb view sending val = 1 parameter here resultcontroller.cs:
[httppost] public actionresult resultweb(int val, formcollection collection) { list<website> list = new list<website>(); // doing stuff list , val return view(list); } this part working , sending parameter view. problem when try same thing html.actionlink on other page
resultweb.cshtml:
<tr> @for (int = 0; <= model.count / 15; i++) { int j = + 1; <td>@html.actionlink(@j.tostring(), "resultweb", new { val = j })</td> } </tr> and when click on 1 of links, doesn't work got error:
description: http 404. resource looking (or 1 of dependencies) have been removed, had name changed, or temporarily unavailable. please review following url , make sure spelled correctly. requested url: /result/resultweb/1 i guess i'm doing wrong don't understand what. can me on ?
thanks !
actionlinks can't post form/data controller. create <a> tags. if want submit form actionlink, use @ajax.actionlinkhelper, or post form jquery alltogether.
also, question has been asked lots of times before on stackoverflow, here or here.
Comments
Post a Comment