日期:2014-05-19  浏览次数:20799 次

好奇怪, 为什么得不到 TextBox 的值呢??????
前台:
<script   language= "javascript ">
function   isInt(straa)
{
alert(straa);
}
</script>
<asp:TextBox   id= "txtaa "   runat= "server "/>

后台:
private   void   Page_Load(object   sender,   System.EventArgs   e)
{
txtaa.Attributes.Add( "onkeydown ",@ "isInt( ' "+   txtaa.Text   + " ') ");
}

为什么弹出对话框中无值呢????
请教各位!!

------解决方案--------------------
txtaa.Attributes.Add( "onkeydown ",@ "isInt(this) ");

function isInt(obj)
{
alert(obj.value);
}
------解决方案--------------------
function isInt()
{
alert(document.getElementById( 'txtaa ' ).value);
}

后台:
private void Page_Load(object sender, System.EventArgs e)
{
txtaa.Attributes.Add( "onkeydown ",@ "isInt(); ");
}
------解决方案--------------------
txtaa.Attributes.Add( "onkeydown ",@ "isInt( ' "+ txtaa.Text + " ') ");
这个时候txtaa.Text没有值
可以改成:
txtaa.Attributes.Add( "onkeydown ",@ "isInt( ' "+ txtaa.ClientID+ " ') ");

function isInt(id)
{
alert(document.getElementById(id).value);
}