[英]Textbox only displays temporarily after javascript function runs
当用户单击gridview标题中的过滤器图标时,我想显示/隐藏一个文本框。 最初,文本框是隐藏的。 当我单击该图标时,文本框将显示一秒钟,然后看起来页面已刷新,并且文本框再次被隐藏。 这是HTML:
<asp:TemplateField HeaderText="Group Name">
<HeaderTemplate> Group Name
<asp:ImageButton ID="uggvGroupFilter" runat="server" ImageUrl="Images/filter.png" OnClientClick="ShowHideFilterTxtBox('uggvTxtNameFilter')" />
<asp:TextBox ID="uggvTxtNameFilter" runat="server" AutoPostBack="true" style="display:none;" ClientIDMode="Static" OnTextChanged="uggvGridFilter_TextChanged">
</asp:TextBox>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="uggvLblGroupName" runat="server" Text='<%# Bind("GroupName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
这是javascript函数:
function ShowHideFilterTxtBox(filterID) {
var obj = document.getElementById(filterID);
if (obj.style.display == "none") {
obj.style.display = "block";
} else {
obj.style.display = "none";
}
}
这是我的文档准备功能:
$(document).ready(function () {
//Configure the DropDownBox using the 'chosen' jquery plugin
$(".chosen-single").chosen({
search_contains: true,
width: "200px",
no_results_text: "Sorry, no match!"
});
});
我还需要在文档准备功能中放入一些内容吗? 为什么文本框的样式仅设置一秒钟,然后返回到原始样式显示“无”?
谢谢。
在客户端函数中return false
。
function ShowHideFilterTxtBox(filterID) {
var obj = document.getElementById(filterID);
if (obj.style.display == "none") {
obj.style.display = "block";
}
else {
obj.style.display = "none";
}
return false;
}
当你打电话时
OnClientClick="return ShowHideFilterTxtBox('uggvTxtNameFilter')"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.