日期:2014-05-20  浏览次数:20913 次

在TEXTBOX中实现onfocus 的功能 txt00.Attributes.Add("onfocus", "")出错的问题
问题内容:

有2个TextBox,txt00,txtRow0
一个数组static   string[]   ArrayDescription   =   new   string[10];
ArrayDescription[0]里有值
我想实现焦点在txt00上时,用数组ArrayDescription[0]给txtRow0.text赋值


我的实现:
txt00.Attributes.Add( "onfocus ",   " <script> document.all. "   +txtRow0.ClientID   + ".value   =   ' "   +ArrayDescription[0]+ " '; </script>     ");

提示错误:
语法错误

说明:
改成下面几中情况也是有错误
11是一字符串
txt00.Attributes.Add( "onfocus ",   "document.all. "   +txtRow0.ClientID   + ".value   =   '11 ';   ");
txt00.Attributes.Add( "onfocus ",   " <script> document.all. "   +txtRow0.ClientID   + ".value   =   '11 '; </script>     ");
txt00.Attributes.Add( "onfocus ",   "document.all. <%=txtRow0.ClientID%> .value   =   '11 ';   ");


求高手教我

------解决方案--------------------
web不懂。大汗,当我路过。。
------解决方案--------------------
txt00.Attributes.Add( "onfocus ", "setValues( ' "+ArrayDescription[0]+ " ') " );

function setValues(strValue)
{
document.all.txtRow0.value=strValue;
}
------解决方案--------------------
楼上正解
------解决方案--------------------
up