![](/img/trans.png)
[英]How can i retrieve the primary key from a Gridview row in aspx to use in a userControl.ascx?
[英]how to access fieldset in usercontrol.ascx from codebehind of the main.aspx page?
實際上我正在使用asp.net和c#開發模板。 我有一個面板,其中包含2個我的用戶控件頁面中的字段集。 我想從main.aspx頁面后面的代碼訪問這2個字段集,這意味着當用戶單擊main.aspx頁面上的link1時,面板將刷新並顯示fielset1以及當用戶單擊link2時,面板將刷新,並且面板顯示fieldset2。 對於頁面的部分刷新,我正在使用updatepanel。 你能指導我如何解決這個問題嗎? 感謝您的考慮。
感謝Denys的跟進。 我已經解決了這個問題。
我在我的usercontrol頁面上放了一個HiddenField變量:
<asp:HiddenField ID="hid_choosingField" Value="" runat="server" />
那么我已經從aspx.cs頁面訪問並更改了它:
Control hidField = WebUserControl31.FindControl("hid_choosingField");
HiddenField ucHidField = (HiddenField)hidField;
ucHidField.Value = "1";
然后我在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>
<% } %>
我希望這會有所幫助。 謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.