如何使用Java脚本识别用户控件中的控件 [英] How to Identiyf a Control which is in User Control using Java Script

查看:80
本文介绍了如何使用Java脚本识别用户控件中的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户控制代码(.ascx)

User Control Code(.ascx)

<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
<input id="Button1" type="button" onclick="txtboxuserControl()" value="showtextboxcontentinalertmsg" />



Java脚本是



Java Script is

function txtboxuserControl()
{

var val=document.getElementById('<%= txtname.ClientID %>').value;
alert(val);

}




请为此提供解决方案
谢谢,
Chandrasekhar.K




Please give the solution for that
Thanks ,
Chandrasekhar.K

推荐答案

如果要在点击事件上调用javascript函数,请点击
do want to call the javascript function on click event if it is so then please use
OnClientClick="return txtboxuserControl();" 


代替onclick()


instead of onclick()


您可以尝试一下吗,
Can you try this,
<input id="Button1" type="button" onclick="txtboxuserControl(''<%= txtname.ClientID %>'')" value="showtextboxcontentinalertmsg" />




and

function txtboxuserControl(controlId)
{


这篇关于如何使用Java脚本识别用户控件中的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆