簡體   English   中英

將值從代碼隱藏發送到隱藏字段

[英]To send value from codebehind to hidden field

在下面的代碼中,我有一個具有值的屬性,我想將該值發送給隱藏字段。pls幫助我做到這一點。

public string FieldLabel { get; set; }

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

您只需將value設置為:

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

     set{
        txthidd.Value = value;
     }
}

在您的代碼隱藏頁面加載中:

txthidd.Value=FieldLabel ;

在您的代碼隱藏頁面中:-

txthidd.Value =“分配的值”;

嘗試這個:

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

然后只需設置您的屬性即可設置隱藏字段值

FieldLabel = "new value";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM