[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

jquery avoid / stop fancybox from popping up in code behind

having fancy box bind to hyperlink

   
<asp:hyperlink id="hlunitprice01" CssClass="pick-price" runat="server">></asp:hyperlink>

$('.pick-price').click(function (e) {
                var url = $(this).attr('href');
                if (url != null && url != '') {
                    e.preventDefault();
                    $.fancybox({
                        href: url + '&sender=' + $(this).attr('id'),
                        type: 'iframe'
                    });
                }
                else {
                    currentPricePicker = $(this).attr('id');
                }
            });

Open in new window


trying to stop / avoid fancybox from popping up from code behind

 if (txtProduct1.Text == "" && txtTo01.Text == "")
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "", "$.fancybox.close();", true);
                lblsavestatus.Text = "sadasadad";
                lblsavestatus.Visible = true;
               

                udp01.Update();

            }

Open in new window

but it will not work
0
doramail05
Asked:
doramail05
1 Solution
 
doramail05Author Commented:
trying the $.fancybox.cancel(); , seems it will disable,

but when try to reable back, it could not work

  if (txtProduct1.Text == "" && txtTo01.Text == "")
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "", "$.fancybox.cancel();", true);
                lblsavestatus.Text = "sadasadad";
                lblsavestatus.Visible = true;
               

                udp01.Update();

            }


            if (txtProduct1.Text != "")
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "", "$.fancybox.init();", true);

                Products pdtProductID1 = Products.GetProductID_ByProductName(txtProduct1.Text.Trim());

Open in new window

0
 
leakim971PluritechnicianCommented:
what about :
if (txtProduct1.Text == "" && txtTo01.Text == "")
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "", "window.dontPopup = true;", true);
                lblsavestatus.Text = "sadasadad";
                lblsavestatus.Visible = true;
               

                udp01.Update();

            }

Open in new window


so we've :

$('.pick-price').click(function (e) {

if(window.dontPopup) return false;

                var url = $(this).attr('href');
                if (url != null && url != '') {
                    e.preventDefault();
                    $.fancybox({
                        href: url + '&sender=' + $(this).attr('id'),
                        type: 'iframe'
                    });
                }
                else {
                    currentPricePicker = $(this).attr('id');
                }
            });

Open in new window

0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now