简体   繁体   中英

To send value from codebehind to hidden field

In the below code i have a property which has value i want to send the value to hidden field .pls help me to do this.

public string FieldLabel { get; set; }

 <asp:HiddenField ID="txthidd" runat="server" />

You just set the value as:

public string FieldLabel { 
     get{
        return txthidd.Value;
     } 

     set{
        txthidd.Value = value;
     }
}

在您的代码隐藏页面加载中:

txthidd.Value=FieldLabel ;

in your codebehind page :-

txthidd.Value = "Assigned Value";

Try this:

Public string FieldLabel
{
    get { return txthidd.Value; }
    set { txthidd.Value = value; }
}

Then just set your property to set the hidden field value

FieldLabel = "new value";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM