0

I have a asp button when clicked upon loads up a popup in css using jquery. This works fine but its not triggering the c# on click event. I have a asp chart and when the pop up loads I want the chart enlarged in the popup window.

Asp Button

<asp:Button ID="lbtnPaging" Runat="server" CustomParameter="Value1" onClick="lbtnPage_Click" class="topopup" Text="Enlarge" ></asp:Button>

Jquery

jQuery(function ($) {

$(".topopup").click(function () {

    loading(); // loading
    setTimeout(function () { // then show popup, deley in .5 second
        loadPopup(); // function show popup
    }, 500); // .5 second
    return false;

});

/* event for close the popup */
$("div.close").hover(
                function () {
                    $('span.ecs_tooltip').show();
                },
                function () {
                    $('span.ecs_tooltip').hide();
                }
            );

$("div.close").click(function () {
    disablePopup();  // function close pop up
});

$(this).keyup(function (event) {
    if (event.which == 27) { // 27 is 'Ecs' in the keyboard
        disablePopup();  // function close pop up
    }
});

$("div#backgroundPopup").click(function () {
    disablePopup();  // function close pop up
});



/************** start: functions. **************/

function loading() {
    $("div.loader").show();

}
function closeloading() {
    $("div.loader").fadeOut('normal');
}



var popupStatus = 0; // set value

function loadPopup() {
    if (popupStatus == 0) { // if value is 0, show popup
        closeloading(); // fadeout loading
        $("#toPopup").fadeIn(0500); // fadein popup div
        $("#backgroundPopup").css("opacity", "0.7"); // css opacity, supports IE7, IE8
        $("#backgroundPopup").fadeIn(0001);
        popupStatus = 1; // and set value to 1


    }

}

function disablePopup() {
    if (popupStatus == 1) { // if value is 1, close popup
        $("#toPopup").fadeOut("normal");
        $("#backgroundPopup").fadeOut("normal");
        popupStatus = 0;  // and set value to 0
    }
}
/************** end: functions. **************/
});    // jQuery End

C# Code

protected void lbtnPage_Click(object sender, EventArgs e)
    {



    }
8
  • 5
    On the jquery you are returning false, and this stops the event from firing. Commented Nov 11, 2013 at 9:27
  • Sam is correct, returning false in javascript will stop its propagation to execute Click event. Commented Nov 11, 2013 at 9:29
  • Thanks Sam. So by not returning false has now worked but the popup which is created just disappears straight away.. ? Commented Nov 11, 2013 at 9:37
  • Click event cause to the page refresh due to which your pop up is being disappeared .. Commented Nov 11, 2013 at 9:38
  • 1
    use ajax webmethods, you can run a static method in code behind instead of the button event which will refresh the page, here is a tutorial : encosia.com/… Commented Nov 11, 2013 at 9:48

1 Answer 1

1

Modify jQuery event into

$(".topopup").click(function () {

    loading(); // loading
    setTimeout(function () { // then show popup, deley in .5 second
        loadPopup(); // function show popup
    }, 500); // .5 second
   // return false;    
});

return false Stops button default behavior. If you want to use return statement return true for calling server side Event

Sign up to request clarification or add additional context in comments.

Comments

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.