Asp.net 将值从codebehind传递到隐藏字段文本框

Asp.net 将值从codebehind传递到隐藏字段文本框,asp.net,Asp.net,在下面的代码中,我得到正则表达式并存储在hidRegExp.Value中。现在我必须将此值传递到隐藏字段文本框。请帮助我完成此操作。 代码隐藏: public List<string> ListOfRegularExpression { get; set; } string strRegularExp = string.Empty; if (ListOfRegularExpression != null) { for (int iRow = 0; iRow < Li

在下面的代码中,我得到正则表达式并存储在hidRegExp.Value中。现在我必须将此值传递到隐藏字段文本框。请帮助我完成此操作。 代码隐藏:

public List<string> ListOfRegularExpression { get; set; } 
string strRegularExp = string.Empty;

if (ListOfRegularExpression != null)
{
    for (int iRow = 0; iRow < ListOfRegularExpression.Count; iRow++)
    {
        strRegularExp += ListOfRegularExpression[iRow].ToString() + "~~";
        if (iRow == ListOfRegularExpression.Count - 1)
        {
            strRegularExp = strRegularExp.TrimEnd("~~".ToCharArray());
            txtField.Attributes.Add("onblur", "javascript:ValidateRegExp('" + txtField.ToString() + "');");
        }
     }
}

hidRegExp.Value = strRegularExp;
规则表达式的公共列表{get;set;} string strRegularExp=string.Empty; if(ListOfRegularExpression!=null) { for(int-iRow=0;iRowhidRegExp.Value=strRegularExp; 代码:


为什么不使用asp隐藏字段标记? 例如:


什么是隐藏字段文本框?很抱歉,它是一个隐藏字段“hidRegExp.Value=strRegularExp;”这应该可以工作,您得到的错误是什么。我在隐藏字段中没有值,我必须将值传递到隐藏字段我尝试过,但来自代码隐藏的值没有传递到隐藏文本您得到的值是什么?你是如何检查它的值的?你是如何检查它的?我是通过这个来检查的,我在这里得到值并传递给隐藏字段lbl.Text=“HiddenField控件的值是”+hidRegExp.value+”;
<input type="hidden" id="hidRegExp" runat="server"  />
<asp:hiddenfield id="ValueHiddenField"
              value="" 
              runat="server"/>