I Successfully created an user control for displaying Error message. now everything works fine but when the message is shown the background controls can be accessed. how to disable the page controls or page from clicking or selecting any controls. and when the message panel is closed it should enable the page controls.
i found the answer 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;
}
}
}
I see, you want it to behave like a modal dialog. It can be done via simple html + javascript. You must create a transparent div overlay that goes over the whole page, so the user instead of clicking the controls it would be clicking on the div. Z-index indicates the position over the rest of controls.
<!-- 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>
Hope it helps.
You can use simply a div and with the help of CSS, you can able to display that div like a modal popup or simply use jquery modal popup http://jqueryui.com/demos/dialog/ or asp.net ajaxcontrol toolkit http://www.asp.net/ajax/ajaxcontroltoolkit/samples/modalpopup/modalpopup.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With