标题:求助:用javascript实现控件隐藏
取消只看楼主
botailang
Rank: 1
等 级:新手上路
帖 子:77
专家分:0
注 册:2007-4-13
结帖率:100%
 问题点数:0 回复次数:1 
求助:用javascript实现控件隐藏


请问各位:能否实现当特定的textbox获得焦点时一个id=“Button1”的button显示,
当textbox失去焦点时此button隐藏。
以下是我写的代码(。NET页面):但运行不出以上所说的效果,请高手帮忙修改一下!谢谢


<%@ Page language="c#" Codebehind="shiyan.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.ZhuCe.shiyan" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>shiyan</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
function show()
{
document.getElementById("Button1").style.display="";
}
function asd()
{
document.getElementById("Button1").style.display="none";
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" onFocus="show()" onBlur="asd()" style="Z-INDEX: 101; LEFT: 272px; POSITION: absolute; TOP: 120px"
runat="server"></asp:TextBox>
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 472px; POSITION: absolute; TOP: 120px" runat="server"
Text="Button" Visible="False"></asp:Button>
</form>
</body>
</HTML>

搜索更多相关主题的帖子: javascript 控件 隐藏 
2007-07-08 11:21
botailang
Rank: 1
等 级:新手上路
帖 子:77
专家分:0
注 册:2007-4-13
得分:0 
功能已经实现了
以下是具体代码:
<%@ Page language="c#" Codebehind="1.aspx.cs" AutoEventWireup="false" Inherits="CalendarTest._1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>shiyan</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" onFocus="show()" onBlur="asd()" style="Z-INDEX: 101; LEFT: 272px; POSITION: absolute; TOP: 120px"
runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server"
Text="Button" style="visibility:hidden"></asp:Button>
</form>
</body>
<script language="javascript">
function show()
{
document.getElementById("Button1").style.visibility="visible";
}
function asd()
{
document.getElementById("Button1").style.visibility= "hidden";
}
</script>
</HTML>

笨人多福
2007-07-10 09:07



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-153708-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.147150 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved