2016-11-28 8 views
0

masterpage, contentplaceholder 및 .ascx 페이지가 있습니다. 사용자가 Masterpage에서 사용자 이름 - 암호를 입력합니다.마스터 페이지에서 ContentPlaceHolder로드 방지

사용자가 잘못된 사용자 이름 & 암호 조합을 입력하면 contentplaceholder의로드를 방지하고 싶습니다. 현재 나는 그 가시성을 무력화시키고 있는데, 속임수를 쓰지만 페이지가 여전히로드되어 데이터베이스 등으로갑니다. 왜냐하면 모든 것이 어쨌든 표시되지 않기 때문에 쓸모가 없습니다.

답변

1

컨트롤 을로드 할 수 있습니다.

private WebUserControl1 userControl; 

protected void Button1_Click(object sender, EventArgs e) 
{ 
    if (loginOK == true) 
    { 
     buildControls(); 
    } 
} 

private void buildControls() 
{ 
    userControl = (WebUserControl1)LoadControl("~/WebUserControl1.ascx"); 
    PlaceHolder1.Controls.Add(userControl); 
} 

동적으로 추가 제어를 Page_Load 마다 (즉, 포스트 백 포함)에 재현 될 필요가있다. 언제든지 사용자가 로그인하면 buildControls()으로 전화하십시오.