1

I have a this part in Edit.chtml looks like

@using (@Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
<article class="SearchBoxCon clearfix">
                        @if (Model.Entity.Document == null)
                        {
                            using (Html.BeginForm("AudioUpload", "Noun", FormMethod.Post, new { enctype = "multipart/form-data", NounId = Model.Entity.Id }))
                            {
                                <article class="BtnCon">

                                    <article class="BrowseBtn">
                                        <input type="file" value="Browse" name="file">
                                    </article>
                                    <article class="BrowseUpload">
                                        <input type="submit" id="AudioUpload" value="AudioUpload">
                                    </article>

                                </article>


                            }

                        }
                        else
                        {
                            <article class="inputBTn">
                                <input type="submit" value="Play">
                                <input type="submit" value="Delete">
                            </article>
                        }
                    </article>

                <article class="inputBTn">
                    <input type="submit" value="Save">
                </article>
                <!-- submit btn ends here -->
                @Html.ActionLink("Back to List", "Index", "Noun/Index", null, new { @class = "BackList" })
            </article>


}

after browsing and upload the file , and click the upload it fire the edit posting action instead of the uploadaudio which looks like

 [HttpPost]
        public ActionResult AudioUpload(HttpPostedFileBase file , int NounId )
        {
AMH
  • 6,363
  • 27
  • 84
  • 135

2 Answers2

0

[ActionName("Edit")] put attribute on your action method it will work

[HttpPost, ActionName("Edit")]
    public ActionResult AudioUpload(HttpPostedFileBase file , int NounId )
    {

make you code like this if your view name is Edit.cshtml

Developerzzz
  • 1,123
  • 1
  • 11
  • 26
  • The current request for action 'Edit' on controller type 'NounController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult AudioUpload(System.Web.HttpPostedFileBase, Int32) on type ArabicELearning.Controllers.NounController System.Web.Mvc.ActionResult Edit(Int32, System.Web.Mvc.FormCollection) on type ArabicELearning.Controllers.NounController – AMH May 13 '14 at 10:45
0

Try like this,

@if (Model.Entity.Document == null)
 {
  using (Html.BeginForm("AudioUpload", "Noun", FormMethod.Post, new { enctype = "multipart/form-data", NounId = Model.Entity.Id,Id="frmAudioUpload" }))
  {<article class="BtnCon">

    <article class="BrowseBtn">
    <input type="file" value="Browse" name="file">
    </article>
    <article class="BrowseUpload">
    <input type="button" id="AudioUpload" value="AudioUpload">
    </article>

    </article>
}}

Script

<script type="text/javascript">
    $(function(){
      $('#AudioUpload').click(function(){
        $('#frmAudioUpload').submit();
      });
    });
</script>
Jaimin
  • 7,964
  • 2
  • 25
  • 32