Setting the value of a HiddenField contained in the Master page from a child page

  Uncategorised

I have a master page that contains the following section:

<section id="content">
                <asp:HiddenField ID="MasterHidden" runat="server" />
                <asp:ContentPlaceHolder ID="Content" runat="server" />
</section>

This master page has two child pages. In one of the child pages is a GridView that contains an image button:

<dx:BootstrapGridViewDataColumn Caption="Requirements" FieldName="Requirements" VisibleIndex="5">
      <DataItemTemplate>
              <asp:ImageButton runat="server" ID="RequirementsBtn" OnClientClick="setMasterFieldValue()"/>
      </DataItemTemplate>
</dx:BootstrapGridViewDataColumn>

When the image button is clicked, I want to run a javascript function that will set the hidden field value in the master page like this:

function setMasterFieldValue(){
    document.getElementById('<%=MasterHidden.ClientID %>').value = "TestValue";
}

I have not been able to get the child page to "talk" to the master page. Is this possible?

Source: Visual Studio Questions

LEAVE A COMMENT