>>>onchange事件?client side event or server side event?if you change the text content and move the focus away from the textbox, the client side onchange should be triggered, see the definition: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/events/onchange.aspif you could try to call onchange() in its onblur event handler, but note from the documentation:"... In addition, this event is executed before the code specified by onblur when the control is also losing the focus..."
建议把相关列转换为模板列,而后给textbox加上id然后在ItemDataBound写相关代码:if(e.Item.ItemType==ListItemType.EditItem){ TextBox myBox1=(TextBox)e.Item.FindControl("id号1"); if (myBox1!=null){ myBox1.Attributes.Add("onchange","js函数") }}
对,用模板列可以做到,不要改好多,很麻烦,,TO 思归,it is server side event;but 我只想编辑状态下触发textbox(是DATAGRID转换而来的)事件;我也试过 TextBox t1=(TextBox)e.Item.Cells[1].Controls[0]; t1.textchanged += new System.EventHandler(t1_textchanged); t1.Attributes.Add("onchange", "__doPostBack('t1','');"); 都不行
t1.textchanged += new System.EventHandler(t1_textchanged); 问题是这个加裁不了,也就是说服务器端事件触发不了
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/events/onchange.aspif you could try to call onchange() in its onblur event handler, but note from the documentation:"... In addition, this event is executed before the code specified by onblur when the control is also losing the focus..."
TextBox myBox1=(TextBox)e.Item.FindControl("id号1");
if (myBox1!=null){
myBox1.Attributes.Add("onchange","js函数")
}}
TextBox t1=(TextBox)e.Item.Cells[1].Controls[0];
t1.textchanged += new System.EventHandler(t1_textchanged);
t1.Attributes.Add("onchange", "__doPostBack('t1','');"); 都不行
问题是这个加裁不了,也就是说服务器端事件触发不了