Accessing value of a hidden field on Masterpage from codebehind

后端 未结 4 580
失恋的感觉
失恋的感觉 2021-01-06 16:40

In a follow up to my previous question, I want to get the value of the hidden input field from the child page codebehind.

I tried HtmlInputHidden hdnID = (H

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-06 17:14

    You should create a property in Masterpage which wrap the HiddenField.

    public String HdnFieldValue
    {
    get
    {
        return hidField.Value;
    }
    set
    {
        hidField.Value = value;
    }
    }
    

    And in page code behind you can access it like this:

    ((YourCustomMaster)Page.Master).HdnFieldValue
    

    If something is not clear please ask me.

提交回复
热议问题