Click here to Skip to main content
15,920,110 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi all. i am trying to pass value from view to modal via beginform.
without use Ajax

What I have tried:

this is my View

@using (Html.BeginForm("ChangeStage", "DropDown", FormMethod.Post))
{
<label>Select Gate </label>
@Html.DropDownListFor(m => m.GateName, new DropboxChange.Models.DropModal().GateDropdown, new { @class = "form-control" })
}




And this is my Controller


public ActionResult ChangeStage( string GateName)
      {
          return View();
      }



i need to pass dropdown value to my controller without any submit button and ajax. please help !!!
Posted
Updated 20-Jan-17 3:16am
Comments
Afzaal Ahmad Zeeshan 16-Jan-17 7:14am    
Without using Ajax, and without using submit button.

What are you up to?
Richard Deeming 16-Jan-17 9:19am    
If you don't have a "submit" button, then you'll have to use Javascript to submit the form.
T_Sub 16-Jan-17 22:21pm    
I need to change dropdown items by using another selection from dropdown
F-ES Sitecore 20-Jan-17 9:27am    
If you're using the default js framework you can use Ajax.BeginForm to have your form submit via ajax. Google "Ajax.BeginForm" or example code.

1 solution

<select id="countrylist">
    <option>Single</option>
    <option>Single2</option>
</select>

$(document).ready(function(){

    $('#countrylist').change(function(e){
        $this = $(e.target);
        $.ajax({
            type: "POST",
            url: "scriptname.asp", // Don't know asp/asp.net at all so you will have to do this bit
            data: { country: $this.val() },
            success:function(data){
                $('#stateBoxHook').html(data);
            }
        });
    });

})




or



< script >
   $(document).ready(function()
   {
       $("#ddlEmployee").on("change", function()
       {
           $.ajax(
           {
               url: '/Home/GetEmployeeRecord?EmployeeId=' + $(this).attr("value"),
               type: 'GET',
               data: "",
               contentType: 'application/json; charset=utf-8',
               success: function(data)
               {
                   $("#partialDiv").html(data);
               },
               error: function()
               {
                   alert("error");
               }
           });
       });
   }); < /script>
 
Share this answer
 

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