如题,添加完后怎么调用这个属性呢?
解决方案 »
- 带数据库的解决方案发布
- asp.net 作出来的页面打印时发现两个问题?
- 有哪位做过工行的支付接口(asp.net的) 能给个完整的解决方案吗
- 大家帮我看看 System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。
- 在线求助 关于asp.net的后退问题
- 急:求asp.net(C#)播放rm文件的源代码
- WIN7 IIS服务->Windows功能没有东西
- [项目]手头一项目,想寻求合作人。
- 求助!导入EXCEL功能本地能正常运行 上传服务器后报错
- 紧急求助!帮我看看这代码哪里出错了?
- UBB表情作出来之后有点小问题,大家给看看,散分
- ASP.NET 定时器访问配置文件问题
不过客户端当然支持这个属性了
<script>
function hehe(param)
{
alert(param);
}
</script>
TextBox1.Attributes.Add("onclick","hehe(this.value);");
<asp:TextBox ID="TextBox1" runat="server" onclick="onclick")
这样写有什么不对阿?
服务器端ID和客户端ID没弄清楚
<script>
function visibleLable()
{
var id = "<%=Lable1.ClientID%>";
document.getElementById("id").visible=true;
}
</script>
TextBox1.Attributes.Add("onclick","visibleLable();");
<asp:TextBox ID="TextBox" onkeyup="change()" runat="server"></asp:TextBox>
<div id='showDiv' style="display:none">
<asp:Label ID='Label1' runat="server"></asp:Label>
</div> <script language="javascript" type="text/javascript" >
function change()
{
//找到TextBox并获得他的内容
var value=document.getElementById('TextBox').value;
var len=value.length;
if(len==0)
document.getElementById('showDiv').style.display='none';
else
document.getElementById('showDiv').style.display='';
}
</script>你看下 是你想要的效果么~
1.cs后台,TextBox1.Attributes.Add("onclick","javascript:visibleLable();");
2.aspx页面上面写一个js函数
function visibleLable()
{
document.all.label1.display = block;
}
<asp:TextBox ID='TextBox' runat="server" onclick="javascript"></asp:TextBox>
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script language="javascript" type="text/javascript" >
function change()
{
//找到TextBox并获得他的内容
var value=document.getElementById('TextBox').value;
var len=value.length;
if(len==0)
document.getElementById('showDiv').style.display='none';
else
document.getElementById('showDiv').style.display='';
}
</script></head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="TextBox" onkeyup="change()" runat="server"></asp:TextBox>
<div id='showDiv' style="display:none">
<asp:Label ID='Label1' runat="server" Text="我是Label"></asp:Label>
</div> </form>
</body>
</html>