asp.net 在asp:textbox失去焦点后 改变页面上一个asp:Label的text值 能不能在JavaScript脚本里实现,因为不想页面被刷新。请问一下怎么实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以啊。<input type="text" onblur="onvalue();" id="aaa" runat="server" /><script>function onvalue(){ document.getElementById("Label1").value="修改后的值";}</script> 在textbox的onblur="onvalue();" 事件中执行下面js代码:<script> function onvalue() { document.getElementById("<%=Label1.ClientID%>").value="修改后的值"; } </script> js代码:function changeText() { document.getElementById("Label1").innerHTML=document.getElementById("<%=TextBox1.ClientID %>").value; }HTML代码:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>后台代码:protected void Page_Load(object sender, EventArgs e) {TextBox1.Attributes.Add("onblur", "changeText();");} 我的意思是在<asp:Textbox ...../> 实现,不是input里面,而且好像textbox 没有onblur事件,只能在<script> function onvalue() { document.getElementById("<%=Lable1 %>").value="修改后的值"; } </script>cs代码protected void Page_Load(object sender, EventArgs e) { Textbox.Attributes.Add("onblar", "onvalue()"); }这样也不能实现 可以啊。 <input type="text" onblur="onvalue();" id="aaa" runat="server" /> <script> function onvalue() { document.getElementById("Label1").innerHTML="修改后的值"; } </script> <asp:TextBox ID ="txt" runat =server Text ="" onblur="hanshu()"></asp:TextBox><script language="javascript">var Lbl= '<%=Label.ClientID %>'function hanshu(){Lblobj = document.getElementById(Lbl)Lblobj.value = "你想改变的值"}</script> 不好意思,请看一下我的条件,我指的事<asp:Textbox.....> onblur 方法可以再前台设置,也可以再后台设置。HTML代码: <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox> <asp:Label ID="Label1" runat="server" Text="Label" onblur="changeText();"> </asp:Label> 也行 我刚刚测试了可以啊。你是document.getElementById("Label1").innerHTML这里要用innerHTML 用value不行,因为label在浏览器中解析为span,没有value OK 脚本:<script language=javascript> function setvalue() { document.getElementById("<%=LabelUser.ClientID%>").value("Text")=""; }</script>asp页面:<asp:TextBox ID="UserNametxt" runat="server" Width="120px" style="margin-left:0px"></asp:TextBox><asp:Label ID="LabelUser" runat="server" ForeColor ="Red" Width="100px" ></asp:Label>后台: protected void Page_Load(object sender, EventArgs e) { UserNametxt.Attributes.Add("onblar", "setvalue()"); } <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><script> function onvalue() { document.getElementById("Label1").innerHTML="修改后的值"; } </script> if (!Page.IsPostBack) { this.TextBox1.Attributes.Add("onblur", "getall()"); } 前台<asp:TextBox ID="UserNametxt" runat="server" Width="120px" style="margin-left:0px"> </asp:TextBox> <asp:Label ID="LabelUser" runat="server" ForeColor ="Red" Width="100px" > </asp:Label> 脚本<script language="javascript"> function setvalue() { document.getElementById('<%=LabelUser.ClientID%>').innerHTML="aaaaaaaaa"; } </script> 后台if (!Page.IsPostBack) { UserNametxt.Attributes.Add("onblur", "setvalue();"); }//楼主请及时结贴。可以了。 前台<asp:TextBox ID="UserNametxt" runat="server" Width="120px" style="margin-left:0px"> </asp:TextBox> <asp:Label ID="LabelUser" runat="server" ForeColor ="Red" Width="100px" > </asp:Label> 脚本<script language="javascript"> function setvalue() { document.getElementById('<%=LabelUser.ClientID%>').innerHTML="aaaaaaaaa"; } </script> 后台if (!Page.IsPostBack) { UserNametxt.Attributes.Add("onblur", "setvalue();"); }//楼主请及时结贴。可以了。 document.getElementById(' <%=LabelUser.ClientID%>').innerHTML这样是正确的 如何使用IBatis.net查询数据库表中指定的字段 求助 关于数组问题 为什么我取不到这个数组的值呢 简单 问题 下班结帖!! 母板页子页! 如何将照片插入到数据表中? 关于编译错误问题 如何用if语句判断combox里面的值发生改变 EXTJS Store 使用Sync方法提交后,如何回调是否成功? 如何在datagrid中加入checkbox控件? 赌球 做了一个网站发布到IIS上出错 请教各位 关于方向按键的问题
<script>
function onvalue()
{
document.getElementById("Label1").value="修改后的值";
}
</script>
<script>
function onvalue()
{
document.getElementById("<%=Label1.ClientID%>").value="修改后的值";
}
</script>
{
document.getElementById("Label1").innerHTML=document.getElementById("<%=TextBox1.ClientID %>").value;
}HTML代码:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Label ID="Label1" runat="server"
Text="Label"></asp:Label>后台代码:protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Attributes.Add("onblur", "changeText();");
}
<script>
function onvalue()
{
document.getElementById("<%=Lable1 %>").value="修改后的值";
}
</script>
cs代码
protected void Page_Load(object sender, EventArgs e)
{
Textbox.Attributes.Add("onblar", "onvalue()");
}
这样也不能实现
<input type="text" onblur="onvalue();" id="aaa" runat="server" /> <script>
function onvalue()
{
document.getElementById("Label1").innerHTML="修改后的值";
}
</script>
<script language="javascript">
var Lbl= '<%=Label.ClientID %>'
function hanshu()
{
Lblobj = document.getElementById(Lbl)
Lblobj.value = "你想改变的值"
}
</script>
HTML代码: <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>
<asp:Label ID="Label1" runat="server"
Text="Label" onblur="changeText();"> </asp:Label> 也行
这里要用innerHTML 用value不行,因为label在浏览器中解析为span,没有value
<script language=javascript>
function setvalue()
{
document.getElementById("<%=LabelUser.ClientID%>").value("Text")="";
}
</script>asp页面:
<asp:TextBox ID="UserNametxt" runat="server" Width="120px" style="margin-left:0px"></asp:TextBox>
<asp:Label ID="LabelUser" runat="server" ForeColor ="Red" Width="100px" ></asp:Label>
后台:
protected void Page_Load(object sender, EventArgs e)
{
UserNametxt.Attributes.Add("onblar", "setvalue()");
}
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<script>
function onvalue()
{
document.getElementById("Label1").innerHTML="修改后的值";
}
</script>
if (!Page.IsPostBack)
{
this.TextBox1.Attributes.Add("onblur", "getall()");
}
<asp:TextBox ID="UserNametxt" runat="server" Width="120px" style="margin-left:0px"> </asp:TextBox>
<asp:Label ID="LabelUser" runat="server" ForeColor ="Red" Width="100px" > </asp:Label>
脚本
<script language="javascript">
function setvalue()
{
document.getElementById('<%=LabelUser.ClientID%>').innerHTML="aaaaaaaaa";
}
</script>
后台
if (!Page.IsPostBack)
{
UserNametxt.Attributes.Add("onblur", "setvalue();");
}
//楼主请及时结贴。可以了。
<asp:TextBox ID="UserNametxt" runat="server" Width="120px" style="margin-left:0px"> </asp:TextBox>
<asp:Label ID="LabelUser" runat="server" ForeColor ="Red" Width="100px" > </asp:Label>
脚本
<script language="javascript">
function setvalue()
{
document.getElementById('<%=LabelUser.ClientID%>').innerHTML="aaaaaaaaa";
}
</script>
后台
if (!Page.IsPostBack)
{
UserNametxt.Attributes.Add("onblur", "setvalue();");
}
//楼主请及时结贴。可以了。
这样是正确的