Mahesh Patil

Mahesh Patil

  • NA
  • 41
  • 10.5k

MVC dynamically assign action method

Apr 13 2015 10:20 AM
I want to bind diff action method in single using form function,see the below code that i have stuck


  @using (Html.BeginForm(null, null, FormMethod.Post, new { name = "myForm", id = "myForm" }))
    {
  @Html.Hidden("ConsumerServiceAndPeriod.OriginalEndHour", Model.ConsumerServiceAndPeriod.ServiceAndPeriod.EndHour)
  @Html.Hidden("ConsumerServiceAndPeriod.OriginalEndMinute",
  @Model.ConsumerServiceAndPeriod.ServiceAndPeriod.EndMinute)
        @Html.Hidden("ConsumerServiceAndPeriod.PayCycleStartDate", Model.PayCycleBeginDate.ToShortDateString())
     
      <div id="divclockin">
            <button type="submit" name ="Create" value="ClockOut" id="btnclockin" class="submitbutton big blue" onclick ="location.href'(@Url.Action("Create", "ClockInOut", new { Model.EmployeeID, Model.ProgramID }))'"></button>
          
        </div>
        <div id="divclockout">
            <button type="submit" name="Edit" value="ClockOut" id="btnclockout" class="submitbutton big blue" onclick ="location.href'(@Url.Action("Edit", "ClockInOut", new { Model.EmployeeID, Model.ProgramID, Model.ConsumerID, Model.UserID }))'"></button>
           
        </div>
}

in that code need to assign action method dynamically,now code can only redirect on create i want also on edit action method.

Thanks in advance


Answers (1)