0

The situation is to open a fancy box on the page load,

Please find the below html, and the code behind I am using but with no success.

protected void Page_Load(object sender, EventArgs e)
        {
            if (SessionController.CurrentMember != null)
            {
                if (Request.IsAuthenticated)
                {
                    int memberId = SessionController.CurrentMember.MemberID;
                    bool checkaccepted = CheckAcceptedTermsandConditions(memberId);

                    if (!checkaccepted)
                    {
                        string script = @"<script>$(document).ready(function() {

                 $(""#onlineCasinoTandC"").fancybox({
                 'transitionIn'  :   'elastic',
                 'transitionOut' :   'elastic',
                  'speedIn'     :   600, 
                    'speedOut'    :   200, 
                    'overlayShow'   :   false,
                     'overlayOpacity':   0.5,
                       'width'         :   800,
                        'showCloseButton':  true,
                         });
                    $(""#onlineCasinoTandC"").click();
                    });</script>";

                        ClientScript.RegisterStartupScript(this.GetType(), "fancybox", script);
                        onlineCasinoTandC.HRef = "/Common/EN/TermsandConditions.aspx";
                    }

                }
            }

        }

Regards Srividhya

4

2 回答 2

0

delete the extra comma at the end of this line

'showCloseButton':  true

And if u want to trigger, Click event, it should be

$('#foo').trigger('click');
于 2012-04-17T10:39:06.623 回答
0

Please find the below solution.

on page load

string script = @"<script type=""text/javascript"">$(document).ready(function() {$(""#termsandConditions"").fancybox({'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':200,'overlayShow':false,'overlayOpacity': 0.5,'width':800,'href':""/Contents/Common/EN/TermandConditions.aspx""}).trigger('click');});</script>";
                    Type cstype = this.GetType();
                    ClientScriptManager cs = Page.ClientScript;

                    if (!cs.IsStartupScriptRegistered(cstype, script))
                    {
                        cs.RegisterStartupScript(cstype, "fancybox", script);
                    }

Regards Vidya

于 2012-04-19T10:30:46.343 回答