I'm attempting to change all TextBoxes into labels on my page using the following code:
foreach (Control ctrl in masterform.Controls)
{
if (ctrl.GetType() == typeof(TextBox))
{
TextBox t = ctrl as TextBox;
t.ReadOnly = true;
t.BackColor = transparent;
t.BorderWidth = 0;
}
}
However, I wrapped all the text boxes in an update panel which prevents me from accessing them. So I tried this:
foreach (Control ctrl in masterform.Controls)
{
if (ctrl is UpdatePanel)
{
UpdatePanel s = ctrl as UpdatePanel;
if (s == PartPanel)
{
foreach (Control ctrl2 in s.Controls)
{
if (ctrl2 is TextBox)
{
TextBox t = ctrl2 as TextBox;
t.ReadOnly = true;
t.BackColor = transparent;
t.BorderWidth = 0;
}
}
}
}
}
This only shows the panels control count as 1, even though there are multiple textbox controls inside. Any assistance on this issue would be greatly appreciated.
Additionally, I have checkboxes that are mutually exclusive: If #1 is checked, #2 or #3 cannot be checked, and vice versa. I've written a function to handle this, but it only works if the update panel does not update:
var objChkd;
$(document).ready(function()
{
$('.mutuallyexclusive1').click(function ()
{
checkedState = $(this).attr('checked');
$('.mutuallyexclusive2:checked').each(function ()
{
$(this).attr('checked', false);
});
$(this).attr('checked', checkedState);
});
$('.mutuallyexclusive2').click(function ()
{
checkedState = $(this).attr('checked');
$('.mutuallyexclusive1:checked').each(function ()
{
$(this).attr('checked', false);
});
$(this).attr('checked', checkedState);
});
});
<input id="Chk1" type="checkbox" runat="server" class="mutuallyexclusive1" /><br />
<input id="Chk2" type="checkbox" runat="server" class="mutuallyexclusive2" /><br />
<input id="Chk3" type="checkbox" runat="server" class="mutuallyexclusive2" /><br />
The issue arises when an update panel's update() function is triggered, causing the checkboxes to lose connection with the JavaScript function they are meant to call. Any assistance on resolving this problem would be highly appreciated. Thank you.