Object does not save it state in Url.action

395 Views Asked by At

I am devloping an app using jqueyrmobile framework in .NET MVC3. I am creating a ListView using a loop

<ul data-role="listview">
    @foreach (var item in Model)
    {
      <li><a href="@Url.Action("Index","Transaction",item)">
            <div style="vertical-align:text-top;padding:1px;font-size:large">  
              @Html.DisplayFor(modeItem => item.title)
              <span style="font-size:small;text-align:right">
                @Html.DisplayFor(modeItem => item.balance)
                [email protected](modeItem => item.currency) 
              </span>
            </div>
          </a>
      </li>   
    }    
</ul>

This works fine and I am getting object item in Index Action of Transaction Controller; but for similer code for another page

 <ul data-role="listview">
       @foreach (var item in Model)
        {
          <li><a href="@Url.Action("optionDialog",item)" data-rel="dialog" >
          <div>@Html.DisplayFor(modeItem => item.brTitle)</div></a></li> 
        }       
    </ul>

I am getting null item object in optionDialog action. Though it made call to Action, the object is null. Any one please help me.

2

There are 2 best solutions below

0
On BEST ANSWER

I got the solution there is microsoft bug which dont work for some time to call to its own controller action after replacing

<li><a href="@Url.Action("optionDialog",item)" data-rel="dialog" > 

with

<li><a href="@Url.Action("optionDialog","ControllerName",item)" data-rel="dialog" > 

i got my result

1
On

The problem it's that you're passing wrong the item to the action

 "@Url.Action("optionDialog",item)" <--- wrong

Tried like this

 "@Url.Action("optionDialog", new { fooParameter= item})"