Tuesday, 27 August 2013

Accessing object in parent user control from child user control

Accessing object in parent user control from child user control

So I have a user control, Parent.ascx:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Parent.ascx.cs"
Inherits="Parent" %>
<%@ Register TagPrefix="cc" TagName="Child" Src="~/Child.ascx" %>
<asp:HiddenField ID="hfId" runat="server" />
<cc:Child ID="child1" runat="server" />
My child control Child.ascx contains a button, and in the code-behind I'd
like to access the value of the hidden field hfId in the click event of
that button
I can't use a user control attribute and set it on Page_Load because the
value of that hidden field is changing through jQuery events in the
Parent.ascx control

No comments:

Post a Comment