我试图将接受的答案应用于此问题How to access html form input from asp.net code behind
和其他类似问题。
我有以下HTML输入,用于显示日期选择器:
FROM:<input type="text" runat="server" name="popupDatepickerFrom" id="popupDatepickerFrom">
然后此代码检索值:
string myStringFromTheInput = popupDatepickerFrom.Value;
Response.Write(myStringFromTheInput);
Response.End();
但这不会返回任何东西。我做错了什么?
答案 0 :(得分:2)
确保您的输入位于表单元素中,如本页所示:
答案 1 :(得分:1)
尝试
string text = " ( ((abc ) def)ghi)";
text = text.Replace("(","( ").Replace(")"," )");//Add aditional space no matter if this one already have it.
while(text.Contains(" ")){//===>To while text contains double spaces
text = text.Replace(" "," ");//===>Replace spaces for a single space;
}
答案 2 :(得分:1)
您应该可以从以下数据访问popupDatepicker:
string myStringFromTheInput = String.Format("{0}", Request.Form["popupDatepickerFrom"]);
Response.Write(myStringFromTheInput);
Response.End();