我现在的DataGrid有两个摸板列.
均放置了一个TextBox, ID分别是:TxtYearNum ,TxtCompute
我想在鼠标移开TxtYearNum时,自动为TxtCompute赋值(TxtCompute=TxtYearNum+2)我在ItemDataBind中增加代码:
foreach( DataGridItem di in DataGrid1.Items)
{
TextBox txtYearNum;
txtYearNum = (TextBox)di.FindControl("TxtYearNum");
string s = txtYearNum.Parent.ClientID;
string[] a =txtYearNum.Parent.ClientID.Split('_');
string txtYearNumID = a[0]+"__"+a[2]+"__txtYearNum"; TextBox txtCompute;
string[] aa = txtCompute.Parent.ClientID.Split('_');
string txtComputeID = aa[0]+"__"+aa[2]+"__txtCompute"; txtYearNum.Attributes.Add("onblur","compute('"+txtYearNumID+"','"+txtComputeID+"');");
}.js函数:
function compute(txt1, txt2)
{
alert('hi');
txt2.value = txt1.value;
}
均放置了一个TextBox, ID分别是:TxtYearNum ,TxtCompute
我想在鼠标移开TxtYearNum时,自动为TxtCompute赋值(TxtCompute=TxtYearNum+2)我在ItemDataBind中增加代码:
foreach( DataGridItem di in DataGrid1.Items)
{
TextBox txtYearNum;
txtYearNum = (TextBox)di.FindControl("TxtYearNum");
string s = txtYearNum.Parent.ClientID;
string[] a =txtYearNum.Parent.ClientID.Split('_');
string txtYearNumID = a[0]+"__"+a[2]+"__txtYearNum"; TextBox txtCompute;
string[] aa = txtCompute.Parent.ClientID.Split('_');
string txtComputeID = aa[0]+"__"+aa[2]+"__txtCompute"; txtYearNum.Attributes.Add("onblur","compute('"+txtYearNumID+"','"+txtComputeID+"');");
}.js函数:
function compute(txt1, txt2)
{
alert('hi');
txt2.value = txt1.value;
}
解决方案 »
- 页面间传递大量数据的最佳方法
- 上传图片如何在DATALIST上生成缩略图?
- 调用其它页面方法的问题!
- 关于多人在线聊天的设计与实现
- 刚才重定向问题已结贴,再开一贴求加载前重定向
- 有个用户控件,要显示一个图片,图片路径是定死的,而用户控件可能被放到任何路径去,问,用户控件中的图片路径怎么写?
- 下载的Microsoft.Web.UI.WebControls的treeview控件显示有问题??
- 找.net高手!
- aspx如何接收CS客户端Post过来的Json数据?
- 谁会写Web Form Control,哪里有比较好的例子。
- asp.net 2.0 读取txt 文件内容分别以,割开, 以每行Enter为结束。 存入SQL2000 数据库 中
- 读取TextBox1文件内容 存入SQL2000 数据库 中
{
alert("hi");
if(txt1.value = null)
{
alert('kong');
}
else
{
alert('not kong!');
txt2.value = txt1.value;
alert(txt1.value);
}
}这样的话是:
弹出 not kong!
然后弹出: undefined可是txt1.value不空啊
的确是少了=
现在是
if(txt1.value = null)
{
alert('kong');
}结果是真反了个 'kong'我现在郁闷的是我怎么取不到txt1.value.
改为
compute("+txtYearNumID.ClientID+","+txtComputeID.ClientID+")
var a=document.getElementById(txt1)
var b=document.getElementById(txt2)
把下面的改为
foreach( DataGridItem di in DataGrid1.Items)
{
TextBox txtYearNum;
txtYearNum = (TextBox)di.FindControl("TxtYearNum");
string s = txtYearNum.Parent.ClientID;
string[] a =txtYearNum.Parent.ClientID.Split('_');
string txtYearNumID = a[0]+"__"+a[2]+"__txtYearNum"; TextBox txtCompute;
string[] aa = txtCompute.Parent.ClientID.Split('_');
string txtComputeID = aa[0]+"__"+aa[2]+"__txtCompute"; txtYearNum.Attributes.Add("onblur","compute('"+txtYearNumID+"','"+txtComputeID+"');");
}改为
foreach( DataGridItem di in DataGrid1.Items)
{
TextBox txtYearNum;
txtYearNum = (TextBox)di.FindControl("TxtYearNum");
string txtYearNumID = txtYearNum.ClientID; TextBox txtCompute;
txtCompute = (TextBox)di.FindControl("txtCompute");
string txtComputeID = txtCompute.ClientID; txtYearNum.Attributes.Add("onblur","compute('"+txtYearNumID+"','"+txtComputeID+"');");
}
不就行了。干嘛还要分割
var b=document.getElementById(txt2)