2012-04-17 95 views
0

的情況是打開看中盒上的頁面加載,打開的fancybox在頁面加載

請找到下面的HTML,和後面的代碼我使用的,但沒有成功。

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"; 
        } 

       } 
      } 

     } 

問候 Srividhya

回答

0

請找到下面的解決方案。

在頁面加載

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); 
        } 

問候 維迪亞

0

在此行的末尾刪除多餘的逗號

'showCloseButton': true 

如果ü要觸發,點擊事件,它應該是

$('#foo').trigger('click'); 
+0

它不工作...我想... – Vidya 2012-04-17 12:03:19