Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I had tried this link but not working Simple Implementation of MVC Cascading Ajax Drop Down[^]

Issue: if i select drop down it is hitting "create action-method" not "SelectCategory action-method"
Posted
Comments
[no name] 7-Jul-15 0:26am    
Let us see your code?

--Check here
http://www.c-sharpcorner.com/UploadFile/4d9083/creating-simple-cascading-dropdownlist-in-mvc-4-using-razor/
Member 11800920 7-Jul-15 0:52am    
Requirement :To display some-text in a Display-Box,when user changes values in a Dropdownlist.For this purpose i used PartialView, Ajax.BeginForm and Jquery.change function.

Issue : In the main-View* i am using **@html.Beginform() and @Ajax.BeginForm is used in partial view, so while i changes the value in Dropdownlist, Jquery Form submit is calling @html.Beginform() in main-View other than @Ajax.BeginForm

Expected Behavior:Jquery Form submit should call @Ajax.BeginForm in partial View

//following Scripts are included in View, Partial-View
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>


In Main View
@model Shopping.Models.Mob
//Issue:This "Html.BeginForm" is called during submitting from partial View
@using (Html.BeginForm("MobileSell", "MobileSell", FormMethod.Post))
{
<table>
<tr><td>**@Html.Partial("_SelectedMobileList", Model)**</td>
</tr>
<tr><td><div id="NextFields">**@Html.Partial("_SelectedMobileDetails", Model)**</div></td>
</tr>
</table>
}



In _SelectedMobileList Partial-View
@using (Ajax.BeginForm("FillMobileDetails", "MobileSell", new AjaxOptions { HttpMethod ="POST",
UpdateTargetId ="NextFields",
InsertionMode = InsertionMode.Replace}))
{
<td>@Html.DropDownListFor(x => x.MobileName, Model.MobileList, "select one", new { id="Drop1"})</td>
}

<script>
$(document).ready(fun1)

function fun1()
{ alert("test1"); $("#Drop1").change(fun2); }

function fun2()
{alert("test2");

//Jquery function calling submit-form
//Expected to invoke "Ajax.BeginForm" but invoking "html.BeginForm"
$(this).parents('form').submit();

}
</script>



In _SelectedMobileDetails Partial-View,which need to display test
@model Shopping.Models.Mob
@Html.DisplayFor(x=>x.MobileEmi)



In Controller
//Issue: Invoking this action-method.
public ActionResult MobileSell()
{
ObjectResult<sp_fetch_mobile_details_result> objResult = objContext.SP_Fetch_Mobile_Details();
SelectList objSelectList = new SelectList(objResult.ToList(), "MobileName", "MobileName");
objMobile.MobileList = objSelectList;
return View(objMobile);
}

[HttpPost]
//Excepted: To invoke this Action Method
public PartialViewResult FillMobileDetails(Mob Model)
{
Response.Write("test3");
Model=new Mob();
Model.MobileEmi="somEmi";
return PartialView("_SelectedMobileDetails",Model);
}

nb:Any doubts please may ask me and help me to fix this

1 solution

First of all, ask this the author of the article your question. To do so, load the article page, locate "Comments and Discussions", click "Add a Comment or Question" and ask your question.

The author will receive a notification on your question and a chance to answer you. If you post your code sample, format it nicely. This is how:

HTML
<pre lang="HTML">

<!-- your ASP.NET code sample goes here -->

</pre>

See the menu on top of the post editing area for other kinds of HTML formatting.

Also, avoid posting any code in comments, use "Improve question" or formatting in the post in the "Comments and Discussion".

—SA
 
Share this answer
 
v2
Comments
Member 11800920 7-Jul-15 4:07am    
@Sergey Alexandrovich: in that article , author didn't replay for any of the previous questions
can you help me to do aut0postbacking in .net MVC, any small example is fine
Sergey Alexandrovich Kryukov 7-Jul-15 10:57am    
Does the code downloaded from the article page work?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900