0

First thank for looking. First let me state I really am lame at Javascript. I'll try and be as helpful as I can. I have 2 ASP.NET forms. 1 has a button on it. The second is a form with a button on it to submit. I am not using an inline hidden div. I am using Colorbox, the most current version as of 3/20/13. I am using VS 2012 4.5. Jquery 1.9. I would like to launch form 2 from form 1... have the user fill in the information click the submit button on it and display in the SAME colorbox that it was submitted and allow them to close the Colorbox with the X. So far here is aprox where I am. I have changed this so many times I'm kind of lost. Most of this ick is from code I found.

Form 1 to launch Form 2 (works as expected)

$(".nameofbuttonclassform1").colorbox({ transition: "fade", width: "800", height: "680", overlayClose: false, href: "Form2.aspx" });

Form 2 button click displays Form 1 in the Colorbox and kills the postback to do the serverside work Does NOT work as needed. I have tried many variations of this so I'm plugging this in since its closer then anything else.

        $('#Form2Submitbutton').click(function(e){

            e.preventDefault();

            var url = $(this).attr('href');

            $.ajax({
                type: 'GET',
                url: url,
                dataType: 'html',
                cache: true,
                beforeSend: function () {
                    $('#cboxLoadedContent').empty();
                    $('#cboxLoadingGraphic').show();
                },
                complete: function () {
                    $('#cboxLoadingGraphic').hide();
                },
                success: function (data) {
                    $('#cboxLoadedContent').append(data);
                }
            });






        });

So I am completely stuck. If you have any ideas, they have to be better then mine.

  • If `$('#Form2Submitbutton')` references a form's `input type="submit"`, you have to use the form's `submit` event and `return false;` from within it. The form is submitting, not the `submit` button, so your browser will still submit the form otherwise. – Jared Farrish Mar 21 '13 at 00:57
  • I'm using a ASP.NET image button. It has two events. OnClicntClick for clientside and OnClick for server. If I return False on the OCS event it fires first which kills the postback and the OC event never gets fired. – David Young Mar 21 '13 at 05:39
  • An [`input[type=image]`](http://jsfiddle.net/userdude/ur4xa/) inside a `form` always acts as an `input[type=submit]`, so it's the same thing. The `image button` control is NOT what you should be looking at, it's the `form` and it's `submit` event. And don't be afraid to right-click, view source on the markup and code; it's much easier if you separate the client code and get to know it as well as whatever produced it. – Jared Farrish Mar 21 '13 at 05:50
  • Although the OP was after something different (disabling the `submit` button), read the somewhat comical back and forth on the same `submit` event concept in [this answer's comments](http://stackoverflow.com/questions/5691054/disable-submit-button-on-form-submit/5691065#5691065). – Jared Farrish Mar 21 '13 at 05:52
  • Jared what is the best way to see what is being generated when the colorbox is open? You can't just right click because it only shows the source from the base form? By the way thank you for the help. – David Young Mar 21 '13 at 15:19
  • Chrome Console or Firefox's Firebug add-on, right-click, Inspect Element. There's all kinds of ways to get information on the page from there. – Jared Farrish Mar 21 '13 at 15:29
  • OK I tried your code on the button and it now allows the code behind(server event) to fire. I commented out all of my code on the form page, the ($('#Form2Submitbutton').click(function(e){) code. So now the colorbox collapses away and all I am left with is the results from clicking the button on the form2(the actual full page itself with the results). So I'm halfway there. – David Young Mar 21 '13 at 15:52
  • What do I need to do that will keep the colorbox open and display the results of the button click? My code just sticks the original page(form1) in place. I have a serverside label on my form2 that I want to simply change to tell the person the form was submitted, I can now do that from my click event form2 because of your code. I don't have a third page for success or a fourth for error. – David Young Mar 21 '13 at 15:52

0 Answers0