2009-05-20 5 views
1

私は、ユーザーがシステムにログインしているかどうか(セッション値をチェックして)ページの読み込みとログインしていない場合、ログイン用のjQueryUIダイアログが表示されます。ASP.NET、jQueryのUIダイアログが1〜2秒間ページに表示される

私のASPXページには、headタグ

<style type="text/css"> 
    body { font-size: 62.5%; } 
    label, input { display:block; } 
    input.text { margin-bottom:12px; width:95%; padding: .4em; } 
    fieldset { padding:0; border:0; margin-top:25px; } 
    h1 { font-size: 1.2em; margin: .6em 0; } 
    div#users-contain { width: 350px; margin: 20px 0; } 
    div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; } 
    div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; } 
    .ui-button { outline: 0; margin:0; padding: .4em 1em .5em; text-decoration:none; !important; cursor:pointer; position: relative; text-align: center; } 
    .ui-dialog .ui-state-highlight, .ui-dialog .ui-state-error { padding: .3em; } 


</style> 
<script type="text/javascript"> 
$(function() { 

    var name = $("#name"), 
     email = $("#email"), 
     password = $("#password"), 
     allFields = $([]).add(name).add(email).add(password), 
     tips = $("#validateTips"); 

    function updateTips(t) { 
     tips.text(t).effect("highlight",{},1500); 
    } 


    function checkRegexp(o,regexp,n) { 

     if (!(regexp.test(o.val()))) { 
      o.addClass('ui-state-error'); 
      updateTips(n); 
      return false; 
     } else { 
      return true; 
     } 

    } 

    $("#dialog").dialog({ 
     bgiframe: true, 
     autoOpen: false, 
     height: 250, 
     modal: true, 
     buttons: { 
       Cancel: function() { 
       $(this).dialog('close'); 
       },         
       NewUser: function() { 
       $(this).dialog('close'); 
       window.location.href="Register.aspx"; 
       }, 
       'Sign in': function() { 
       var bValid = true; 
       allFields.removeClass('ui-state-error'); 


       bValid=true; 
       isValidationFails=false; 
       if (bValid) 
       {    
             // Go to another page 

        } 
       } 
      } 
     }, 
     close: function() { 
      allFields.val('').removeClass('ui-state-error'); 
     } 
    }); 



    $('#create-user').click(function() { 
     $(this).dialog('close'); 
     window.location.href="Register.aspx" 
    }) 
    .hover(
     function(){ 
      $(this).addClass("ui-state-hover"); 
     }, 
     function(){ 
      $(this).removeClass("ui-state-hover"); 
     } 
    ).mousedown(function(){ 
     $(this).addClass("ui-state-active"); 
    }) 
    .mouseup(function(){ 
      $(this).removeClass("ui-state-active"); 
    }); 

//}); 
var isAuthenticated = $("#isAuthenticated").val(); 
if (isAuthenticated && isAuthenticated == "false") 
{ 
    $("#dialog").dialog("open"); 
} 

})でこれらのスクリプトが含まれています。 (をPage_Loadで)

</script> 

サーバ側コード

if (Session["trCustomerId"] != null) 
     { 
      Response.Write("Logged in user"); 
      ClientScript.RegisterHiddenField("isAuthenticated", "true"); 
     } 
     else 
     { 
      ClientScript.RegisterHiddenField("isAuthenticated", "false"); 
     } 

プログラムが正常に動作しています。しかし、問題は、ページがロードされているときに、画面に1〜2秒間UIDialog divを表示してから消えてしまうことです。私はこのように見せたくありません。誰かがこれを解決する方法を教えてもらえますか?

答えて

2

ダイアログマークアップのスタイルを次のように設定してみてください。

#dialog{ 
    display: none; 
} 

これで、dialog.openがそれをしない場合に表示できます。

$('#dialog').show() 
+0

ありがとうございました。出来た – Shyju

0

これを試してください。これは、html code type style = "display:none;" #ダイアログについて ブラウザの読み込み時に最初に

関連する問題