2011-09-02 4 views
1

내부 condition.Not 구문 문제처럼 .Looks 작업에 두 html.Textboxfor 필드를 해제하려고하는 경우 사용하는 방법.

$(document).ready(function() { 

     if (Model.Key == Guid.Empty) { 
      $("#@idPasswordTextBox").attr('disabled', 'disabled'); 
      $("#@idConfirmPasswordTextBox").attr('disabled', 'disabled'); 
     } 

}); 

는인가요 방법은

+2

당신의 ID를은'@ '기호로 시작? –

+2

선택자에서'@'기호를 제거해보십시오. 실제로, # @ idPasswordTextBox 대신에'# idPasswordTextBox'를 사용합니다. – 65Fbef05

+0

이들은 다음과 같이 정의 된 로컬 변수입니다. \t string idPasswordTextBox = "_Password_"+ @ Model.Key.ToString(); \t 문자열 idConfirmPasswordTextBox = "_ConfirmPassword_"+ @ Model.Key.ToString(); ID는 다음과 같이 지정됩니다. @ Html.PasswordFor (model => model.Password, new {id = @idPasswordTextBox}) – Patty

답변

0

것은 당신의 면도기 코드를 포장하려고? $(document).ready(function() {} 내부 if 조건을 사용하는()

if (Model.Key == Guid.Empty) { 
     $("#@(idPasswordTextBox)").attr('disabled', 'disabled'); 
     $("#@(idConfirmPasswordTextBox)").attr('disabled', 'disabled'); 
    } 

는 자바 스크립트 문자열을 탈출해야

0
@if(Model.Key == Guid.Empty) { 
    <text>$("#idPasswordTextBox").attr('disabled', 'disabled');</text> 
} 
당신의 선택에서

제거 @, 또는 사용을 두 번 @@

@if(Model.Key == Guid.Empty) { 
    <text>$("#@@idPasswordTextBox").attr('disabled', 'disabled');</text> 
} 
+0

은 사용자를 이해하지 못합니다. 면도기가 필요하거나 'if'조건이 유효 할 때만 확인란의 클릭 핸들러를 호출해야합니다. – Patty

+0

을 표시하는 – Samich

+0

업데이트 코드 – Samich

관련 문제