0

i am working on mvc dot net, and i have one button and when i clicked on this button i want to display one popup box with textarea and text of text area will insert on db. this all working with MVC razor.

like this..my code on this URL

How to call client side click on html submit button in mvc

Community
  • 1
  • 1
shweta
  • 27
  • 3
  • 11
  • First show the code you have done so far. – arin1405 Apr 11 '14 at 09:13
  • i have only one submit button.. and click on submit button i want to show popup box that having one textarea and ok button. that's it.. – shweta Apr 11 '14 at 10:04
  • You can use JQuery dialog and for your`OK` button an ajax call. better to show what you have done so there will be help –  Apr 11 '14 at 10:16
  • http://stackoverflow.com/questions/22989631/how-to-call-client-side-click-on-html-submit-button-in-mvc/22990214?noredirect=1#comment35154558_22990214 this is my code – shweta Apr 12 '14 at 07:47

1 Answers1

1

See this code for jquery ui dialog box https://jqueryui.com/dialog/#default

You will have to create a dialog like so and submit your value via ajax:

<script>
    $(function() {
        $('#myButton').click(function(){
            $('#dialog').dialog('open');
        });

        $( "#dialog" ).dialog({
            autoOpen: false,
            buttons: {
                "OK": function() {
                    $.ajax({
                        url: '@Url.Action("myAjaxMethodAction", "myController")',
                        type: 'post',
                        data: $('#myForm').serialize(),
                        success: function() {
                            $('#dialog').dialog('close');
                        }
                    });
                }
            }
        });
    });
</script>

<div id="dialog" title="Basic dialog">
    <form id="myForm">
        <textarea id="myTextArea"></textarea>
    </form>
</div>

Alternatively, you could put your text area in a Razor form and just submit the page on submit which would post it to a regular MVC action like you would regularly.

user1477388
  • 20,790
  • 32
  • 144
  • 264
  • not working for me.. :( . only showing text box on my page . i want to show this popup on button click . and submit this txtarea data on db. – shweta Apr 14 '14 at 09:20
  • See my edit; when you click a link with the ID of `myButton` it will open the `dialog` which displays a text box. When you click OK, it should serialize the data in `myForm` and send it to the URL specified as JSON. – user1477388 Apr 14 '14 at 13:01