我在DATAGRID点了编辑进入编辑状态,在编辑状态下,DATAGRID表格转为textbox,这里我想在修改完textbox1的内容,当焦点转换时怎样可以使它触发onchange事件!?(难点那编辑状态的textbox都是转换后得到的,我尝试加裁事件但不成功)

解决方案 »

  1.   

    >>>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..."
      

  2.   

    建议把相关列转换为模板列,而后给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函数")
       }}
      

  3.   

    对,用模板列可以做到,不要改好多,很麻烦,,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','');"); 都不行
      

  4.   

    t1.textchanged += new System.EventHandler(t1_textchanged);
    问题是这个加裁不了,也就是说服务器端事件触发不了
      

  5.   

    用模版列可以解决问题,而且你的dopostback中的t1最好换成clientid。