2009-05-18 3 views
1

버튼이있는 ASP.NET 페이지가 있습니다. 사용자가 버튼을 클릭하면 사용자가 로그인했는지 로그인하지 않으면 로그인 할 수있는 모달 팝업이 표시됩니다 (jQueryUI 사용). btnLogin의 Click 이벤트에서 jQueryDialog.But에 의해 표시 될 Div에 하나의 텍스트 상자 (txtPassword) 및 단추 (btnLogin) 컨트롤을 배치 했으므로 텍스트 상자에 입력 된 텍스트 값을 읽을 수 없습니다. txtPasswordjQueryUI가있는 ASP.NET : 버튼 클릭 이벤트에서 텍스트 상자 값이 null로 바뀌고 있습니다.

아래는 내 코드

<form id="form1" runat="server"> 
<div> 
    <br /> 
    <asp:TextBox ID="txtModelId" runat="server" Text=""></asp:TextBox><br /> 

    <asp:Button ID="btnGo" runat="server" Text="Go" OnClick="btnGo_Click" /> 
    <br /> 
    <asp:Label ID="lblUserMsg" runat="server" Text="Label"></asp:Label></div> 
    <div id="divContentHolder"> 
    <div class="demo"> 

    <div id="dialog" title="Login with your TradeIn Account"> 
    <p id="validateTips">Enter your EmailId & password</p> 


    <fieldset> 
     <label for="email">Email</label> 
     <asp:TextBox ID="txtEmail" CssClass="text ui-widget-content ui-corner-all" runat="server" ></asp:TextBox> 
     <label for="password"> 
     <asp:TextBox ID="TextBox1" runat="server" Text="sample"></asp:TextBox>Password</label> 
     <asp:TextBox ID="txtPassword" CssClass="text ui-widget-content ui-corner-all" runat="server" ></asp:TextBox> 
     <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" UseSubmitBehavior="false"/> 
    </fieldset> 

    </div><!--dialog--> 
    </div><!--demo--> 
    </div><!--divContentHolder--> 

</form> 

서버 측 코드입니다

protected void btnGo_Click(object sender, EventArgs e) 
{ 
    CheckUserLoggedIn(); 
} 

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

    protected void btnLogin_Click(object sender, EventArgs e) 
    { 
     string txtSample= TextBox1.Text; // this is showing the value 'sample' 
     string txtPass= txtPassword.Text; // this is showing null 

     if (txtPass == "shyju") 
     { 
      Session["username"] = txtPassword.Text; 
      Response.Redirect("TestingModal.aspx"); 
     } 
    } 

대화

를 렌더링하는 내 자바 스크립트 코드$ (함수() {

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 checkLength(o,n,min,max) { 

      if (o.val().length > max || o.val().length < min) { 
        o.addClass('ui-state-error'); 
        updateTips("Length of " + n + " must be between "+min+" and "+max+"."); 
        return false; 
      } else { 
        return true; 
      } 

    } 

    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: 300, 
      modal: true, 
      buttons: { 
        'Create an account': function() { 
          var bValid = true; 
          allFields.removeClass('ui-state-error'); 

          bValid=true; 
          if (bValid) { 

            /*$('#users tbody').append('<tr>' + 
              '<td>' + name.val() + '</td>' + 
              '<td>' + email.val() + '</td>' + 
              '<td>' + password.val() + '</td>' + 
              '</tr>'); */ 

              alert("Check User Credentials") 
            $(this).dialog('close'); 
          } 
        }, 
        Cancel: function() { 
          $(this).dialog('close'); 
        } 
      }, 
      close: function() { 
        allFields.val('').removeClass('ui-state-error'); 
      } 
    }); 



    $('#create-user').click(function() { 
      $('#dialog').dialog('open'); 
    }) 
    .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") 
{ 
// Display the modal dialog. 
$("#dialog").dialog("open"); 
} 
}); 
열심히 내가 그것을 무엇입니까 버튼 클릭 이벤트 .IN 내 ASPX 파일의 HTML 부분에 '샘플'로 TextBox1에의 텍스트 속성 값을 구분했다

. 그러나 다른 텍스트 상자, txtPassword의 텍스트 속성이 나에게 null 값

을주고있다 앞서 사전에

감사

+0

실제로 무슨 일이 일어나고 있는지에 대한 충분한 코드가 없습니다. Page_Load 이벤트에서 값을 설정하고 있습니까? 값을 지우는 jQuery 코드가 있습니까? – jfar

답변

0

txtPa을 얻으려고 가서 저를 인도하십시오 이 같은 ssword 값

관련 문제