How to disable controls on an ASP.NET page when usercontrol is selected?

I successfully created a user control to display an error message. now everything works fine, but when the message is displayed, you can access the background controls. how to disable page or page controls by clicking or selecting any controls. and when the message bar is closed, it should include page controls.

I found friends friends.

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;
                    } 
}
        }
+5
source share
3 answers

, , . html + javascript. div-, , div. Z-index .

<!-- Div Overlay -->
<div id="div-overlay" style="position: absolute; height: 100%; width: 100%; z-index: 200; display: none; opacity: 0.0"></div>

<!-- Scripts to show/hide overlay -->
<script type="text/javascript">
function showOverlay() {
    var e = document.getElementById('div-overlay');
    e.style.display = 'block';
}

function hideOverlay() {
    var e = document.getElementById('div-overlay');
    e.style.display = 'none';
}
</script>

, .

+2

Are you trying to create a modal dialogue? If so, you can use the ModalPopupExtender control from asp.net ajax. check this link:

http://msdn.microsoft.com/en-us/magazine/cc164247.aspx

0
source

All Articles