The only way I've seen this done in the tutorials I've looked at, they say to create a new .ascx and choose the option "create" for View Content.
I want to be able to customize mine more with specific ID's... So, if I have a Customer that has data: string FirstName
, string LastName
, string Address
. How can I bind my textboxes so that when the form is submitted, the textbox values get used as FirstName/LastName/Address?
Here's my form:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MySite.Models.Entities.EntityFramework.Customer>" %>
<% using (Html.BeginForm())
{ %>
<%= Html.TextBox("myform_CustFirstName") %>
<%= Html.TextBox("myform_CustLastName") %>
<%= Html.TextBox("myform_CustAddr") %>
<input type="submit" value="Add Customer" />
<% } %>
What do I need to do to bind each to the correct Model parameter?
I tried this:
<% Model.FirstName = Html.TextBox("myform_CustFirstName") %>
and that gave me an error...
any ideas?