Problem getting value of a ASP.NET form field from httpContext
I have declared a form input in my ASP.NET ascx file:
<input type="hidden" id="hidServiceType" name="hidServiceType" val开发者_开发问答ue="somevalue" />
And in the web service / web method, I am trying to get the value of this
HttpContext postedContext = HttpContext.Current;
serviceType = postedContext.Request.Form["hidServiceType"];
I can dig down into postedContext.Request.Form and see 2 keys one being "hidServiceType" but "serviceType" variable = "";
What am I missing, this seems so trival.
Why don't you just add a runat="server" attribute to your input field and then access it as you do everything else from the code-behind?
精彩评论