Search code examples
c#asp.netajaxpanelfieldset

how to access fieldset in usercontrol.ascx from codebehind of the main.aspx page?


actually i'm developing template using asp.net and c#. i have one panel which contain 2 fieldset in my usercontrol page. i wand to access these 2 fieldset from the code behind of the main.aspx page, which means when the user click on the link1 at the main.aspx page the panel will be refresh and shows the fielset1 and when the user click on the link2, the panel will be refresh and panel shows the fieldset2. for the partial refreshing of the page i'm using the updatepanel. could you please guide me how to get ride of this problem. appreciate your consideration.


Solution

  • thanks Denys for following up. i have fix the problem.
    i have put one HiddenField variable at my usercontrol page:

    <asp:HiddenField ID="hid_choosingField" Value="" runat="server" />
    

    then i have accessed and changed it from aspx.cs page:

    Control hidField = WebUserControl31.FindControl("hid_choosingField");
        HiddenField ucHidField = (HiddenField)hidField;
        ucHidField.Value = "1";
    

    then i have put a if condition at the ascx page to check what is the HiddenField value and base on the value i show the related fieldset:

    <% if (hid_choosingField.Value == "1")
       { 
    %>
        <fieldset id="uc3Fieldset1" style=" height:350px;">
        <legend>New Module Details</legend>
    
            <asp:Label ID="Label2" runat="server" ForeColor="blue" Text="This is User Control 3 Panel 1 Fieldset 1" />
        </fieldset>
    
        <%}
       else if (hid_choosingField.Value == "2")
       { %>
    
        <fieldset style=" height:350px;">
        <legend>New Module Details</legend>
    
            <asp:Label ID="Label1" runat="server" ForeColor="blue" Text="This is User Control 3 Panel 1 Fieldset 2" />
    </fieldset>
    
        <% } %>
    

    i hope it would be helpful. thanks