Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FormCollection Empty in ASP.NET Mobile View

When I am using this code as web view, it works fine, but when with developer option in Chrome I select Mobile View, FormCollection shows empty strings in the controller

VIEW (Edit updtaed)

<div class="page product-details-page deal-product-details-page">
    @using (Html.BeginForm("AddProductToCart_Details", "DealProduct", new { productId = Model.Id, shoppingCartTypeId = 1 }, FormMethod.Post))
    {
        <div class="page-body">

            @using (Html.BeginRouteForm("Product", new { SeName = Model.SeName }, FormMethod.Post, new { id = "product-details-form" }))
            {
                            @{
                                var dataDictAttributes = new ViewDataDictionary();
                                dataDictAttributes.TemplateInfo.HtmlFieldPrefix = string.Format("attributes_{0}", Model.Id);
                                @Html.Partial("~/Views/Product/_ProductAttributes.cshtml", Model.ProductAttributes, dataDictAttributes)

                            }
                            <!--gift card-->
                            @{
                                var dataDictGiftCard = new ViewDataDictionary();
                                dataDictGiftCard.TemplateInfo.HtmlFieldPrefix = string.Format("giftcard_{0}", Model.Id);
                                @Html.Partial("~/Views/Product/_GiftCardInfo.cshtml", Model.GiftCard, dataDictGiftCard)

                            }
                            <!--rental info-->
                            @{
                                var dataDictRental = new ViewDataDictionary();
                                dataDictRental.TemplateInfo.HtmlFieldPrefix = string.Format("rental_{0}", Model.Id);
                                @Html.Partial("~/Views/Product/_RentalInfo.cshtml", Model, dataDictRental)

                            }
                            <!--price & add to cart-->
                            @{
                                var dataDictPrice = new ViewDataDictionary();
                                dataDictPrice.TemplateInfo.HtmlFieldPrefix = string.Format("price_{0}", Model.Id);
                                @Html.Partial("~/Views/Product/_ProductPrice.cshtml", Model.ProductPrice, dataDictPrice)


                                @Html.Partial("~/Views/Product/_ProductTierPrices.cshtml", Model.TierPrices)
                            }
                            <!--wishlist, compare, email a friend-->

                                    <!--attributes-->
                                    @{
                                        var item = @Model.AssociateProductAttributesList.Where(x => x.Item1 == data.Id).Select(x => x.Item2).ToList()[0];
                                        bool isAttributes =false;
                                    }

                                    <div class="popup" data-popup="[email protected]">
                                        <div class="popup-inner">
                                            <h2>@data.Name</h2>
                                            <p>@data.ShortDescription</p>

                                            <br />
                                            @foreach (System.Collections.DictionaryEntry value in item)
                                            {
                                                var val = data.Id + "_" + value.Key.ToString();

                                                isAttributes = true;
                                                @*<div class="attributes">*@
                                                <dl>
                                                    <dt id="product_attribute_label_19">
                                                        <label class="text-prompt">
                                                            @value.Key.ToString()
                                                        </label>
                                                    </dt>
                                                    <dd id="product_attribute_input_19" class="product_attribute_inputdiv_@val">
                                                        @Html.DropDownList("Attributes," + data.Id + "," + value.Key.ToString(), new SelectList((System.Collections.IEnumerable)value.Value, "Id", "Name"), "--- Please select ---")

                                                    </dd>
                                                </dl>
                                                @*</div>*@
                                            }
                                            <br />
                                            <div onclick="ImageBlur('[email protected]')" class="buttons" style="text-align:left;">
                                                <input class="button-1" data-popup-close="[email protected]" type="button" value="Add to back" />
                                            </div>

                                            <a class="popup-close" data-popup-close="[email protected]" href="#">x</a>
                                        </div>
                                    </div>
                                    @if (item.Count == 0)
                                    {
                                        @Html.Hidden("Attributes," + data.Id + ",", "0")
                                        <div class="popup" data-popup="[email protected]">
                                            <div class="popup-inner">
                                                <h2>@data.Name</h2>
                                                <p>@data.ShortDescription</p>


                                                <div onclick="ImageBlur('[email protected]')" class="buttons" style="text-align:left;">
                                                    <input class="button-1" data-popup-close="[email protected]" type="button" value="Add to back" />
                                                </div>


                                                <a class="popup-close" data-popup-close="[email protected]" href="#">x</a>
                                            </div>
                                        </div>
                                    }



                                @if (isAttributes)
                                {
                                    <a style="color: blue;" data-popup-open="[email protected]" href="#">
                                        <img id="[email protected]" src="~/Themes/Playground/Content/img/dealselectattribut.png" class="select-atr-img" style="width: 50%; margin-bottom: 10px;"/>
                                    </a>
                                }
                            </div>
                         }


                    </div>

                    <div>

                    </div>
                    @{
                        var dataDictAddToCart = new ViewDataDictionary();
                        dataDictAddToCart.TemplateInfo.HtmlFieldPrefix = string.Format("addtocart_{0}", Model.Id);
                        <div class="overview" style="width:100%; margin-left:auto">

                            @Html.Partial("~/Views/Product/_AddToCart.cshtml", Model.AddToCart, dataDictAddToCart)

                        </div>
                    }


                </div>
                        }

        </div>
                        }
</div>

Controller

 public ActionResult AddProductToCart_Details(int productId, int shoppingCartTypeId, FormCollection form)
        {

            if (_productService.IsDealProducts(productId))
            {
                if (!IsCompleteSelected(form))
                {
                    return Json(new
                    {
                        success = false,
                        message = "    Plese select all associated product attribute    "
                    });
                }
            }
//more code here
}

Normal View (Web View) enter image description here

Mobile View

enter image description here

like image 860
trighati Avatar asked Oct 03 '16 13:10

trighati


1 Answers

Form in form is not allowed. This is your issue.

like image 190
Dexion Avatar answered Oct 24 '22 11:10

Dexion