如何使用输入类型=隐藏控件? [英] How to use input type=hidden control?

查看:49
本文介绍了如何使用输入类型=隐藏控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

我是第一次使用隐藏的文本框

Hi Friends,

I''m using the hidden textbox for the first time

< input type="hiddden"/>


我以前没用过.应用程序要求将数据库中的值绑定到隐藏的输入标签.我尽了最大努力,但没有找到解决方案.请帮帮我.
下面给出的是我在.aspx文件中的代码:


I haven''t used it before. Application requires that a value from the database bound to a hidden input tag. I tried my best but didn''t get solution. Please help me out.
Given below is my code in the .aspx file:

<input id="Item_ID" type="hidden" name="Item_ID" runat="server"/>


并在.cs文件中:


and in the .cs file:

int.TryParse(Item_ID.Value, out subpageid);
Subpage subpage = subpageid > 0 ? new Subpage(subpageid) : new Subpage();



修正了他的拼写,并添加了asp.net标签[/编辑]



Fixed his spellings and added asp.net tag[/Edit]

推荐答案

嘿,

如果您没有为隐藏控件分配值,那么它将不会在回发时返回值.就这么简单:)
Hey there,

If you don''t assign a value to the hidden control then it won''t return a value on postback. Simple as that :)
<input id="Item_ID" type="hidden" name="Item_ID" runat="server" value="2" />


请,请参阅我设置的值属性.

DaveAuld试图告诉您的是,这是一个专业论坛,而不是SMS服务.因此,请尽量使用正确的拼写.

@DaveAuld:也许,他可能不会说流利的英语.为了以防万一,给他割个懒腰:)

希望对您有所帮助


Please, See the value attribute I''ve set.

What DaveAuld is trying to tell you is that, this is a professional forum, not a SMS service. So use correct spellings to the best of your strength.

@DaveAuld: Perhaps, he might not be fluent in using his english. Just in case, cut him some slack :)

Hope this helps, regards




您可以直接将值绑定到隐藏字段,例如,
值=''<%= YourServerSideVariable%>''

在这里请注意,"YourServerSideVariable"必须是公共的.


谢谢
Hi,

You can bind value to hidden field directly like,
value = ''<%= YourServerSideVariable%>''

Here note that "YourServerSideVariable" must be public.


Thanks


这篇关于如何使用输入类型=隐藏控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆