Xavier
Xavier

Reputation: 1794

How to close a pop up window by clicking the close button?

This is my div in the aspx page:

<div id="pop-up">

    <button id="btnClose">Close</button>
        <div id="mopopuptitle">
        </div>
        <table id="popuptable" cellspacing="15">
        </table>
    </div>

This is my js code:

$('td#' + parentElement).find('span.download_active').next().hover(function (e) {
                topPos = e.pageY - ($('div#pop-up').height()) - 35;
                leftPos = e.pageX - ($('div#pop-up').width()) - 30;
                if (leftPos < 0) { leftPos = 10; }
                GetAssociatedPeopleList(json_row.value.task_id);
                $('div#pop-up').show().css('top', topPos).css('left', leftPos).appendTo('body');
                $('#mopopuptitle').html('People who have taken up this Request');
                $('#btnClose').button({ icons: { primary: "ui-icon-closethick" }, text: false })
            .css({ width: '30px', height: '20px', position: 'absolute', right: -'25px', top: '-25px' })
            .click($(this).close());
            }, function() {


            });

The above code has some business logic. Dont bother about that.. All i need is when i click the close button the pop up has to be closed..

I have tried these lines..

$('div#pop-up').show().css('top', topPos).css('left', leftPos).appendTo('body');
                $('#mopopuptitle').html('People who have taken up this Request');
                $('#btnClose').button({ icons: { primary: "ui-icon-closethick" }, text: false })
            .css({ width: '30px', height: '20px', position: 'absolute', right: -'25px', top: '-25px' })
            .click($(this).close());

I couldn achieve by trying this code.. What should i change?? Is there any alternative for this?? Please help me out..

Upvotes: 0

Views: 9599

Answers (3)

iBoonZ
iBoonZ

Reputation: 1045

You can try the below code as well.

Jquery:

$('div#pop-up').dialog({ 
      buttons: [{ text: "Close" , click: function () {
    $(this).dialog("close"); }
                }]
 });

Upvotes: 0

adripanico
adripanico

Reputation: 1058

You can control it from code behind:

The Page.asp:

<div id="pop-up" runat="server">
   <button id="btnClose" runat="server" Text="Close" />
    ...
</div>

The Page.asp.vb:

Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
  pop-up.visible = False
End Sub

Upvotes: 0

Tarun Tak
Tarun Tak

Reputation: 411

Try this code on "OnClientClick" event of your close button

$find('yourpopId').hide();

Upvotes: 2

Related Questions