C# 如何从main.aspx页面的代码隐藏访问usercontrol.ascx中的字段集?

C# 如何从main.aspx页面的代码隐藏访问usercontrol.ascx中的字段集?,c#,asp.net,ajax,panel,fieldset,C#,Asp.net,Ajax,Panel,Fieldset,实际上,我正在使用asp.net和c#开发模板。我有一个面板,在我的usercontrol页面中包含2个字段集。我想从main.aspx页面的代码隐藏处访问这2个字段集,这意味着当用户单击main.aspx页面上的link1时,面板将刷新并显示fielset1,当用户单击link2时,面板将刷新并显示字段集2。对于页面的部分刷新,我使用updatepanel。你能指导我如何解决这个问题吗。 感谢您的考虑。感谢Denys的跟进。我已经解决了这个问题。 我在usercontrol页面上放置了一个Hi

实际上,我正在使用asp.net和c#开发模板。我有一个面板,在我的usercontrol页面中包含2个字段集。我想从main.aspx页面的代码隐藏处访问这2个字段集,这意味着当用户单击main.aspx页面上的link1时,面板将刷新并显示fielset1,当用户单击link2时,面板将刷新并显示字段集2。对于页面的部分刷新,我使用updatepanel。你能指导我如何解决这个问题吗。
感谢您的考虑。

感谢Denys的跟进。我已经解决了这个问题。
我在usercontrol页面上放置了一个HiddenField变量:

<asp:HiddenField ID="hid_choosingField" Value="" runat="server" />
然后,我在ascx页面上设置了一个if条件,以检查HiddenField值是多少,并根据该值显示相关字段集:

<% 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>

    <% } %>

新模块详细信息
新模块详细信息
我希望这会有帮助。
谢谢

在usercontrol代码中为这两个字段创建属性。在main.aspx页面上,您只需使用userControl.propertyName syntax访问属性。感谢您的回复,但您能否告诉我如何在ascx.cs页面中为字段集构建属性,并在aspx.cs页面中将字段集的可见性更改为false或true。因为我可以为面板做,但我不能为面板内的字段集做。非常感谢。我当然可以尝试,请张贴您的用户控制标记,以便我可以或多或少地看到字段的类型,以便能够提供更好的答案
<% 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>

    <% } %>