0

I want to add style class to my submit button, like this I can use bootstrap Modal to show the result in this modal. This is my code :

@model pfebs0.Models.StatModel

@using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    ...
    <p>
        <button type="submit" class="mybtn" >Get</button>
        ..
}

<div id="modalDiv" class="modal fade" >
    <div class="modal-dialog"></div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    <script>
        $(function () {
            $.ajaxSetup({ cache: false });
            $('.mybtn').click(function () {
                $('.modal-dialog').load(this.href, function () {
                    $('#modalDiv').modal({
                        backdrop: 'static',
                        keyboard: true
                    }, 'show');
                    bindForm(this);
                });
                return false;
            });
        });
    </script>
}

The problem when I add the class class="mybtn" my form is not submitted any more when I click on it, If I remove class="mybtn" the button works fine.
Also I have tried to use this : <input type="submit" value="Create" class="mybtn" /> but same problem

2
  • remove "return false;" from script tag Commented May 27, 2014 at 18:44
  • @Azim no this dosn't work for me Commented May 30, 2014 at 19:49

1 Answer 1

1

That is because you are returning false in your script, which prevents form to submit or go any further.

<script>$(function () {

            $.ajaxSetup({ cache: false });
            $('.mybtn').click(function () {
                $('.modal-dialog').load(this.href, function () {
                    $('#modalDiv').modal({
                        backdrop: 'static',
                        keyboard: true
                    }, 'show');
                    bindForm(this);
                });
                return false; // you should disable it or find another way to do 
            });
});
    </script>
Sign up to request clarification or add additional context in comments.

2 Comments

Sorry but how to do that ?
Also Is it possible to send Data without using form ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.