Values that are supposed to be binded using model binder have to be properties in model.
Up vote 0 down vote favorite share g+ share fb share tw.
Here is my Controller: public ActionResult Deposit() { return View(); } HttpPost public ActionResult Deposit(DepositTicket dt) { using (var db = new MatchGamingEntities()) { MembershipUser currentUser = Membership.GetUser(); Guid UserId = (Guid)currentUser. ProviderUserKey; var AccountId = from a in db. Accounts where a.
UserId == UserId select a. AccountId; BankTransaction transaction = new BankTransaction(); transaction. Amount = dt.
Amount; transaction. AccountId = AccountId.SingleOrDefault(); transaction. Created = DateTime.
Today; transaction. TransactionType = "Credit"; Debug. Write("Amount: " + transaction.
Amount + " AccountId " + transaction. AccountId); db. BankTransactions.
AddObject(transaction); db.SaveChanges(); return View(); } } Here is my View: @model MatchGaming.Models. DepositTicket @{ ViewBag. Title = "Deposit"; } Deposit @using (Html.BeginForm()) { @Html.
ValidationSummary(true) DepositTicket @Html. LabelFor(model => model. Amount) @Html.
EditorFor(model => model. Amount) @Html. ValidationMessageFor(model => model.
Amount) } For some reason in my HttpPost the DepositTicket dt. Amount is returning 0 even though I put a number in the form and submit, I printed the number out and its always 0. I don't think the post variables are going through.
EDIT: DepostTicket Class: public class DepositTicket { Required Display(Name="Deposit Amount") Range(5.00, 999999999999999999999999999.0, ErrorMessage = "Price must be above $5") public decimal Amount; } EDIT 2: Here is the rendered html DepositTicket Amount c# asp.net asp.net-mvc-3 link|improve this question edited Mar 18 '11 at 3:54 asked Mar 17 '11 at 20:16anthonypliu1,132721 73% accept rate.
Can you show the code for the DepositTicket class, that may be helpful. – eulerfx Mar 17 '11 at 20:22 Did you examine in Fiddler/Firebug on what the Http Post looked like? Does the naming convention in Model match the View?
– WorldIsRound Mar 17 '11 at 20:22 Also note you're missing the closing tag for the one – Kensai Mar 17 '11 at 20:24 Thanks for quick response guys, I posted the DepositTicket class – anthonypliu Mar 17 '11 at 20:27 Can you post the actual HTML that is rendered in the browser? – Ryan O'Neill Mar 17 '11 at 21:05.
Values that are supposed to be binded using model binder have to be properties in model public class DepositTicket { Required Display(Name="Deposit Amount") Range(5.00, 999999999999999999999999999.0, ErrorMessage = "Price must be above $5") public decimal Amount { get; set; } }.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.