You must Sign In to post a response.
  • Category: ASP.NET

    Cannot disable labels and hyperlinks in a panel


    I have a panel, in whhich there is a table

    On page load I want to disable this panel, the textboxes and dropdownlists get disabled but not the label and hyperlinks, how do i do that.

    I have set the panel1.enabled =false, but the prob as above, why doesnt label and hyperlink go grey.

    Please help me with this.
  • #765440

    It's highly impossible to say the exact reason without seeing your screen and your code, as per logic if you are disable the parent obviously the child controls also should be disable, but in your case in some where this might be enable again, i guess the problem is you are enable the controls again in some other way. Please debug the code and check line by line if you are using client side scripts then debug in browser and check where it's gets enabled.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #765441
    Ok I have attached the code for my form below please have a look
    I have label1,Label2,Hyperlink1,Hyperlink2 ,radiobutton1(yes),radiobutton2(no)
    If I click radiobutton1(yes) the label1 and hyperlink1 have to be enabled, on pageload they have to be disbaled.

    <tr><td colspan='4' class='hrr'></td></tr>
    <tr><td>Are there up-to-date Site Drawings?
    <a class="tooltip"><img src="info.png" /><span><strong>Site Drawings</strong><br />If these exist please click 'Yes'.</span>
    </td><td><asp:RadioButton ID="RadioButton5" runat="server" Text="Yes" TextAlign="Left" GroupName="Updatedrawing" AutoPostBack="True" OnCheckedChanged="RadioButton5_CheckedChanged" /> <asp:RadioButton ID="RadioButton6" runat="server" Text="No" TextAlign="Left" GroupName="Updatedrawing" AutoPostBack="True" /></td><td><asp:Label ID="Label3" runat="server" Text="I have emailed a copy to" Enabled="False" ViewStateMode="Disabled"></asp:Label> <asp:HyperLink ID="HyperLink1" runat="server" Enabled="False" ><a href='mailto:abc@def.ghi'>Manager</a></asp:HyperLink> </td><td><asp:CheckBox ID="CheckBox1" runat="server" Enabled="False" /></td><td></tr>
    <tr><td>Is there a Comms Room ?</td><td><asp:RadioButton ID="RadioButton7" runat="server" Text="Yes" TextAlign="Left" GroupName="Roomdrawing" AutoPostBack="True" /> <asp:RadioButton ID="RadioButton8" runat="server" Text="No" TextAlign="Left" GroupName="Roomdrawing" AutoPostBack="True" /></td><td><asp:Label ID="Label4" runat="server" Text="I have emailed a copy to" Enabled="False"></asp:Label><asp:HyperLink ID="HyperLink2" runat="server" Enabled="False" ><a href='mailto:abc@def.ghi'>Manager</a></asp:HyperLink> </td><td><asp:CheckBox ID="CheckBox2" runat="server" Enabled="False" /></td></tr>


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

    End Sub

    Protected Sub RadioButton5_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton5.CheckedChanged
    CheckBox1.Enabled = True
    Label3.Enabled = True
    HyperLink1.Enabled = True

  • #765443

    Check your pageload event Ispostback true


    if (!Page.IsPostBack)

    Name : Dotnet Developer-2015
    Email Id :

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #765445
    where do I write this code in Page_Load or Radiobutton5_checkedChanged.??

  • #765448
    Hi Lexi,

    You should write this code in radiobutton checkedchanged event only, but once the event execution is completed again page load event will load again, may be in page load you are disabling the controls again i guess.

    Request you to keep the debugger and check line by line that might be helpful to you...

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #765460
    Hello Naveen
    I tried doing it but that doesnot work...
    Can i have your email add I can send you entire page so that you can have a look and help me pleaseeee

  • Sign In to post your comments