简体   繁体   English

将值从代码隐藏发送到隐藏字段

[英]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. 在下面的代码中,我有一个具有值的属性,我想将该值发送给隐藏字段。pls帮助我做到这一点。

public string FieldLabel { get; set; }

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

You just set the value as: 您只需将value设置为:

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

     set{
        txthidd.Value = value;
     }
}

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

txthidd.Value=FieldLabel ;

in your codebehind page :- 在您的代码隐藏页面中:-

txthidd.Value = "Assigned Value"; txthidd.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";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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