管理表单元素的检测 [英] Managing detection of form elements

查看:63
本文介绍了管理表单元素的检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让它变得简单:我执行了一条sql语句,然后看到num变量为0或1.此外,我还有一个带有2个按钮和一个复选框的表单.

Lets make it simple: I do a sql statement and I see num variable is 0 or 1. Also I have a form with 2 buttons and a checkbox.

<form id="form1" runat="server">
     <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
     <input type="button" onclick="criarNota();" value="Criar Nota" />
     <input type="button" onclick="botaoCarregarNotas();" value="Carregar Notas" />
     <asp:CheckBox id="check" Text="Auto Load" TextAlign="Right" AutoPostBack="True" OnCheckedChanged="Check" runat="server" />
 </form>



我仍然没有为复选框执行动作事件onclick(对DB的SQL查询),但是假设当我选中该复选框时,我希望表单的第二个按钮不出现在下一页加载中(数字值为0).

我该怎么做?



I still didnt do the action event onclick for the checkbox (SQL query to DB), but lets suppose when I check the box I want the second button of the form dont appear on the next page load (num value to 0).

How can I do that?

推荐答案

CheckBox的值保存在会话变量中,然后在页面的OnPageLoad方法中检查该值会话var的值,并根据需要显示/隐藏其他控件.

Save the value of the CheckBox in a session variable, and in the OnPageLoad method of the page, check the value of the session var, and show/hide the other control as appropriate.


当我选中该框时,我希望表单的第二个按钮不出现在下一页加载中(数值为0)"
在玩回发时,您可以直接设置按钮的可见性".

您需要做的就是设置按钮的ID属性以访问它们,并''runat="server"''以便您可以在服务器端的代码中访问它们.
"when I check the box I want the second button of the form dont appear on the next page load (num value to 0)"
When you are playing with postback then you can directly set the ''Visibility'' of the button.

All you need is to put-set an ID property of buttons to access them and ''runat="server"'' such that you can access them in your code behind on server side.


这篇关于管理表单元素的检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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