Currently, I am working on an ASP.NET application that utilizes a collection of UserControls.
Within this application, there is a page that displays various custom UserControls. One of these controls, known as ucA
, includes a small JavaScript Popup that renders another UserControl, referred to as ucB
.
In ucA
, I have defined a public property that interacts with a hidden field also defined within ucA
:
<asp:HiddenField ID="hidWorkDirName" runat="server" />
The property is defined as follows:
public string _hidWorkDirName
{
get { return hidWorkDirName.Value; }
set { hidWorkDirName.Value = value; }
}
In ucB
, there is a TextBox that, upon submission, should update the value of hidWorkDirName
:
protected void btnSubmit_Click(object sender, EventArgs e)
{
ucA parent = (ucA)this.Parent; //referring to ucB in this context
parent._hidWorkDirName = txtName.Text; //updating the TextBox value in ucA
}
During debugging, I can observe that the value is being successfully updated.
However, in ucA
, there is a separate Submit button (different from the one in
ucB</code) where I need to retrieve the value stored in <code>hidWorkDirName
. Yet, despite multiple attempts, the retrieved value always appears as an empty string, as if it was never set.
I have attempted to access the value directly from the hidden field and through the property (_hidWorkDirName
) itself but I cannot seem to retrieve the previously set value.
What could be causing this issue?