开发者

Problem getting value of a ASP.NET form field from httpContext

开发者 https://www.devze.com 2023-02-11 07:15 出处:网络
I have declared a form input in my ASP.NET ascx file: <input type=\"hidden\" id=\"hidServiceType\" name=\"hidServiceType\" val开发者_开发问答ue=\"somevalue\" />

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号