如何使用javascript或代码隐藏在asp.net中显示和隐藏按钮 [英] how to show and hide a button in asp.net using javascript or code behind
问题描述
大家好,
i有1个文本框和2个按钮
2按钮: - 搜索,清除过滤器。
功能是: -
1)clear-filter一直处于禁用状态。点击搜索后,启用clearfilter。
2)然后如果再次点击清除过滤器按钮,则清除过滤器是不可见的。
旧代码: -
在这里,我使用下面的脚本,但没有在chrome工作,所以请帮助我。
hi to all,
i have 1 textbox and 2 button
2 button :- search,clear-filter.
functionality is:-
1) clear-filter always disabled.when you click search,clearfilter enabled.
2) and then if you click clear filter button again clear filter is invisible.
old code:-
here i using this below script but not working in chrome so kindly help me for that.
window.onload = function Showalert() {
var txt = document.getElementById("<%= txtSearch.ClientID %>");
var btn = document.getElementById("<%= BtnClearFilter.ClientID %>");
if (txt.value == "") {
// alert(txt.value);
btn.style.visibility = "hidden";
// when the window is loaded, hide the button if the textbox is empty
}
}
function EnableDisableButton(sender, target) {
var first = document.getElementById('<%=txtSearch.ClientID %>');
if (sender.value.length >= 1 && first.value.length >= 1) {
document.getElementById('<%=BtnClearFilter.ClientID %>').style.visibility = "visible";
}
if (sender.value.length < 1 && first.value.length < 1) {
document.getElementById('<%=BtnClearFilter.ClientID %>').style.visibility = "Hidden";
}
}
因为给出的脚本或代码可能是什么是否可以使用ie以及chrome
because given script or code what ever it may be it will work in ie as well as chrome
推荐答案
使用updatepanel和Visible = true / false
或
http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_style_visibility
use updatepanel and Visible=true/false
or
http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_style_visibility
尝试 jQuery [ ^ ]承诺跨浏览器
特别针对您的问题:
1. https://learn.jquery.com/using-jquery-core/faq/how-do-i-disable-enable-a -form-element / [ ^ ]
2. http://www.w3schools.com/jquery/jquery_hide_show.asp [ ^ ]
Try jQuery[^] which promises to be cross-browser
Specifically to your question:
1. https://learn.jquery.com/using-jquery-core/faq/how-do-i-disable-enable-a-form-element/[^]
2. http://www.w3schools.com/jquery/jquery_hide_show.asp[^]
在javascript中:
document.getElementById('<%= Button1.ClientID%>')。style.visibility =hidden;
in Jquery :
In javascript :
document.getElementById('<%=Button1.ClientID %>').style.visibility = "hidden";
in Jquery :
这篇关于如何使用javascript或代码隐藏在asp.net中显示和隐藏按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!