I have the following idea that i am trying to implement
@foreach (var item in Model)
{
<div>User: @item.Name<br />
Scores: @item.scores<br />
@Html.TextBox("lastvisit");
@Html.ActionLink("Update item", "updateMyItem", new { name = item.Name, lastvisit=????? })
</div>
}
I have seen this SO question Pass text in query string, but that is not what i want..
so my question is .. in the above code how can I replace the (?????) with the value of the textbox(lastvisit) and send the value as a querysting in the URL of the action link ??
Notice that I opted not to use a webform for my own reason and I know how to do it with webform.submit(), but my main concern is how to extract the value of @HTMLhelper.textbox()..
:)
Ok Nilesh I will answer my own question.. but I will cheat from your solution lol cuz it is inspiring .. thanx in advance
<script type="text/javascript">
$(document).ready(function () {
var myMainPath = "updateMyItem";
$("a").each(function(){
var name =$(this).parent("div").child("#itemName").val();
var visit = $(this).parent("div").child("#lastvisit").val();
$(this).attr('href', myMainPath +'?name=' + name + '&lastVisit='+ visit);
});
});
</script>
@foreach (var item in Model)
{
<div>User: <span id="itemName">@item.Name</span><br />
Scores: @item.scores<br />
@Html.TextBox("lastvisit", new { id="lastvisit"});
<a href=""> Update item </a>
</div>
}
you see it can be done by javascript , but i was mistaken to think that you can manipulate it via Razor on the server ..