0

I am working with a project in C#, MVC , asp.net and I want my form on success to add a new button.

@using (Ajax.BeginForm("CreatePaper", "AdminPaper", "Post", new AjaxOptions { OnSuccess = "Success" }))
{
   //some fields to complete 
  <button id="submiter" type="submit" class="btn btn-primary">Create</button>
}
@section scripts
{@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
function Success() {
    console.log("test");//did not know how to add the button, maybe I can use ajax?
}
</script>
}

how can I add a new button next to the "submiter" button?thanks

Note> for some reason I can not see the log in the console. It is not showing anything.

jdod
  • 3
  • 4
  • `$('#submiter').after($('').text('Another button'));` –  Feb 06 '18 at 03:13
  • for some reason, I could not make it work to show the log message.Is there anything I am missing? it neither work the code for adding the button.. – jdod Feb 06 '18 at 03:19
  • What errors are you getting in the browser console? Do you have jquery loaded –  Feb 06 '18 at 03:20
  • I do not get any error in my browser. I have the bundles ready and working,making reference to Jquery – jdod Feb 06 '18 at 03:25
  • And what about `jquery.unobtrusive-ajax.js`? –  Feb 06 '18 at 03:38
  • I think is not coming with the bundles.How can I get it ? I have jquery.validate.unovstrusive. I am using the default configuration for asp.Net projects.Did not touch bundlesconfig – jdod Feb 06 '18 at 03:45
  • You just need to add it to one of your bundles, or directly to the view (without it your making a normal submit - and that alone suggests your POST method is wrong in the controller) –  Feb 06 '18 at 03:47
  • I can not find the Jquery.unobtrusive-ajax.js in my project. where can I get it? is it okay to use Install-Package Microsoft.jQuery.Unobtrusive.Ajax -Version 3.2.3 in the package console? – jdod Feb 06 '18 at 03:51
  • Yes you can download the nuget package. –  Feb 06 '18 at 03:53
  • thanks a lot! can you post it as an answer please? – jdod Feb 06 '18 at 04:00
  • Your question was how to add a button and I have already duped it (no answers can be added) –  Feb 06 '18 at 04:01

0 Answers0