나는 오류 메시지를 표시하기위한 사용자 정의 컨트롤을 성공적으로 만들었습니다. 이제 모든 것이 잘 작동하지만 메시지가 표시되면 배경 컨트롤에 액세스 할 수 있습니다. 페이지 컨트롤이나 페이지를 클릭하거나 컨트롤을 선택하지 못하게하는 방법. 메시지 패널이 닫히면 페이지 컨트롤이 활성화되어야합니다.usercontrol이 선택되었을 때 ASP.NET 페이지에서 컨트롤을 해제하는 방법은 무엇입니까?
대답 친구를 찾았습니다.
void DisableControls(Control parent, bool status)
{
foreach (Control c in parent.Controls)
{
if (c is DropDownList)
{
((DropDownList)(c)).Enabled = status;
}
if (c is Button)
{
((Button)(c)).Enabled = status;
}
if (c is TextBox)
{
((TextBox)c).Enabled = status;
}
if (c is RadioButton)
{
((RadioButton)c).Enabled = status;
}
if (c is ImageButton)
{
((ImageButton)c).Enabled = status;
}
if (c is CheckBox)
{
((CheckBox)c).Enabled = status;
}
if (c is DropDownList)
{
((DropDownList)c).Enabled = status;
}
if (c is HyperLink)
{
((HyperLink)c).Enabled = status;
}
if (c is GridView)
{
((GridView)c).Enabled = status;
}
if (c is Table)
{
((Table)c).Enabled = status;
}
if (c is Menu)
{
((Menu)c).Enabled = status;
}
if (c is TreeView)
{
((TreeView)c).Enabled = status;
}
}
}
사용자 정의 컨트롤이 활성화 될 때 나는 내가 controls.but 컨트롤을 추가 한 div를 가지고 있는데, 호출 한 페이지의 컨트롤도 활성화되어 있습니다. 해당 페이지의 컨트롤을 비활성화하고 싶습니다. –
다음과 같이 간단하게 코드를 크게 간소화 할 수 있습니다. foreach (parent.Controls에서 Control c) {c.Enabled = false; }'Enabled는'Control'의 속성이기 때문에. 답장을 보내 주셔서 감사합니다. – Crisfole
나는 그것을 벌써 시도했다. 그러나 그것을 기울인다 can not는 그것을 성공하게한다. 오류가 발생합니다. –