Head scratching 🙁
I am trying to bind one value to label and back to model from label , but not working
I can see the value in View but after post action controller method Model is not having that value.
Please suggest ! Can’t Label values posted to the server like classic asp.net ?
public class MyModel
{
public MyModel()
{
}
public string FirstName {set; get;}
public string Desciptopn { set; get; }
public string EventDate2 { set; get; }
public bool Failed { set; get; }
}
<%
EventDate2.Text = Model.EventDate2;
%>
<asp:Label ID="EventDate2" runat="server" Text="Label"></asp:Label>
Don’t use server side controls with MVC. These values are not persisted (no viewstate) back to the server. If you need the value passed back as part of the model, you should put it in an HTML input, perhaps hidden, in addition to including the text on the page.
Anything you want sent back needs to be either part of a URL (for a GET request) or a form input. These will get translated to your action method parameters/model.