dimanche 20 avril 2014

Passing value from view to controller


Vote count:

0




Ok, i asked a very simliar question recently and I got good answers back. However, I probably did not express my problem accuratley so I will give it another go here:


This is my view



@using (Html.BeginForm())
{
<h3 class="editable">@Model.Title</h3>

<input type="submit" value="submit">

}


The <h3> has the class "editable" which in this case means it can be edited by an inline-editor.



@Model.Title


Is a propertie from my database that i would like to be able to change with the inline-editor.


This code would generate the same result:



@using (Html.BeginForm())
{
<h3 class="editable">@Model.Title</h3>

<input type="text" id="testinput" name="testinput" />

<input type="submit" value="submit">
}
Controller:


[HttpPost]
public ActionResult FAQ(string testInput)
{


page.Title = testInput;

return View();
}


Allthough, this does not use the inline-editor which I would like.


Is there maybe a way to treat the <h3> as if it was a textbox allowing me to send whatever is in there to the controller?


I want to make clear that i do NOT want to send @model.title to the controller directly. I want to send the value created by clicking on the <h3> and using the inline-editor to change it.


Thank you!



asked 38 secs ago






Aucun commentaire:

Enregistrer un commentaire