En iyi yanıtlayıcılar
asp.net mvc form dan veri alma

Soru
-
@if (Model.IsGiftCard)
{
using (Html.BeginForm("AddToCartProduct", "ShoppingCart", FormMethod.Post))
{
<div class="giftCard">
@T("Products.GiftCard.Field.Fill")
<dl>
<dt>@Html.LabelFor(model => model.RecipientName):</dt>
<dd>
@Html.TextBoxFor(model => model.RecipientName)
</dd>
@if (Model.GiftCardType == Nop.Core.Domain.Catalog.GiftCardType.Virtual)
{
<dt>@Html.LabelFor(model => model.RecipientEmail): </dt>
<dd>
@Html.TextBoxFor(model => model.RecipientEmail)
</dd>
}şeklinde devam eden form sayfam var ve bu formu post ettigimde
[HttpPost]
[ValidateInput(false)]
public JsonResult AddToCartProduct(AddToCartModel model, FormCollection form)
{metodunda yakalıyorum ancak form verilerinin hiçbiri gelmiyor. ancak breakpoint koyunca bu metoda düşüyo. Neden form verileri gelmez ki . Fikriniz var mı ?
Yanıtlar
-
ilk yükleme örneği
public ActionResult Page() { AddToCartModel model = new AddToCartModel(); model.IsGiftCard = true; return View(model); }
.cshtml
@model AddToCartModel @if (Model.IsGiftCard) { using (Ajax.BeginForm("AddToCartProduct", "ShoppingCart", null, new AjaxOptions { HttpMethod = "POST", OnSuccess = "SUCCESS" }, new {name = "mainForm", id = "mainForm"})) { <div class="giftCard"> @T("Products.GiftCard.Field.Fill") <dl> <dt>@Html.LabelFor(model => model.RecipientName):</dt> <dd> @Html.TextBoxFor(model => model.RecipientName) </dd> @if (Model.GiftCardType == Nop.Core.Domain.Catalog.GiftCardType.Virtual) { <dt>@Html.LabelFor(model => model.RecipientEmail): </dt> <dd> @Html.TextBoxFor(model => model.RecipientEmail) </dd> }
AddToCartProduct methodu[HttpPost] public JsonResult AddToCartProduct(AddToCartModel model) { if (!ModelState.IsValid) { return Json(new { Status = false, ErrorMessage = "Hata Mesajı") }, "text/plain"); } string RecipientName = model.RecipientName; //.................. }
- Yanıt Olarak İşaretleyen Özgür Tekbaş 10 Aralık 2013 Salı 10:50
Tüm Yanıtlar
-
-
ilk yükleme örneği
public ActionResult Page() { AddToCartModel model = new AddToCartModel(); model.IsGiftCard = true; return View(model); }
.cshtml
@model AddToCartModel @if (Model.IsGiftCard) { using (Ajax.BeginForm("AddToCartProduct", "ShoppingCart", null, new AjaxOptions { HttpMethod = "POST", OnSuccess = "SUCCESS" }, new {name = "mainForm", id = "mainForm"})) { <div class="giftCard"> @T("Products.GiftCard.Field.Fill") <dl> <dt>@Html.LabelFor(model => model.RecipientName):</dt> <dd> @Html.TextBoxFor(model => model.RecipientName) </dd> @if (Model.GiftCardType == Nop.Core.Domain.Catalog.GiftCardType.Virtual) { <dt>@Html.LabelFor(model => model.RecipientEmail): </dt> <dd> @Html.TextBoxFor(model => model.RecipientEmail) </dd> }
AddToCartProduct methodu[HttpPost] public JsonResult AddToCartProduct(AddToCartModel model) { if (!ModelState.IsValid) { return Json(new { Status = false, ErrorMessage = "Hata Mesajı") }, "text/plain"); } string RecipientName = model.RecipientName; //.................. }
- Yanıt Olarak İşaretleyen Özgür Tekbaş 10 Aralık 2013 Salı 10:50