About using the Jbox dialog box submission does not eject problem solving method _javascript Tips

Source: Internet
Author: User
Jbox is a good dialog box component.
When you use Jbox in the ASP.net Form, you will find that you cannot eject the dialog box problem in the client click event that the button registers.
The performance of the page as a flash on the submission, resulting in a dialog box flashed, or even can not see. Cause the modal dialog box to fail.
First, the button will have the default processing, for the ordinary ASP.net button, will cause the form to submit, submitting the form caused the page to refresh. Therefore, in order to not submit the form, you need to block the default behavior of the button, which can be achieved by following code.
Copy Code code as follows:

function Stopdefault (e) {
Prevent the default browser action (the consortium)
if (e && e.preventdefault)
E.preventdefault ();
Else
A shortcut for stoping the browser action in IE
Window.event.returnValue = false;
return false;
}

Second, when we close the dialog box, we want to be able to submit the form, which can also be done by scripting. is to invoke the Submit method of the Form object submit ();

In the implementation, we also need to find the control's client identity, which can be obtained as follows

Copy Code code as follows:

var Btnsaveid = "<%= This.btnSave.ClientID%>";
var form1id = "<%= This.form1.ClientID%>";

button click on the client to process the following

Copy Code code as follows:

Click event Handling for Registration button
$ ("#" + Btnsaveid). Click (function (e) {

Settings to submit a form when closing a conversation
var options = {
Closed:function () {
Alert ("Submit");
Find the form you want to submit
$ ("#" + form1id). Submit ();
}
};

Show Jbox dialog box
var info = ' JQuery jbox<br/><br/> version: v2.0<br/> Date: 2011-7-24<br/> ';
info + = ' Official website: <a target= ' _blank ' href= ' http://kudystudio.com/jbox ' >http://kudystudio.com/jbox</a> ';
$.jbox (info, options);

To prevent default event handling
Stopdefault (e);

});

For JQuery, returning false in an event-handling method can accomplish a similar function.

But there is a difference between these two ways. Return false not only prevents the event from bubbling up, but also blocks the event itself.
Stopdefault only blocks the default event itself and does not prevent event bubbling.
You can also block event bubbling, which requires the following method to be called.
Copy Code code as follows:

function Stopbubble (e) {
If an Event object is provided, then this is a Non-ie browser
if (e && e.stoppropagation)
and therefore it supports the Stoppropagation () method
E.stoppropagation ();
Else
Otherwise, we need to use the Internet Explorer
Way of cancelling event bubbling
Window.event.cancelBubble = true;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.