日期:2014-05-18  浏览次数:20384 次

关于页面回传值的问题!!
碰到了这样一种怪情况:
在父窗体中放了两个文本框:TextBox1和TextBox7,其中:AutoPostBack= "True ",一个按扭:Button3,当我点击
Button3时弹出一个选择数据的窗体:
Button3.Attributes.Add( "onclick ", "window.open   ( 'f_FoodSelect.aspx ',   '信息列表 ',   'height=400,   width=758,   top=180,left=180,toolbar=no,   menubar=no,   scrollbars=yes,   resizable=no,location=no,   status=no ');   ");  
我在f_FoodSelect.aspx中选择了数据后回传回父窗体中的TextBox7,代码如下:
private   void   DataGrid1_DeleteCommand(object   source,   System.Web.UI.WebControls.DataGridCommandEventArgs   e)
{
DataGrid1.EditItemIndex=(int)e.Item.ItemIndex;

string   s_id=e.Item.Cells[1].Text.ToString();
Response.Write( " <script> ");
Response.Write( "window.opener.document.Form1.TextBox7.value= ' "+s_id.Replace( " ' ", "\ " ")+ " '; ");
Response.Write( "window.close(); ");
Response.Write( "window.close(); ");
Response.Write( " </script> ");
}

在父窗体中我触发这样的事件:
private   void   TextBox7_TextChanged(object   sender,   System.EventArgs   e)
{
TextBox1.Text=TextBox7.Text;
}
问题是这样的:
  为什么我第一次选择数据后不会触发TextBox7_TextChanged事件,而要选择第二次后才会触发TextBox7_TextChanged事件?
我要第一次选择数据后就触发TextBox7_TextChanged事件,我该怎么处理?




------解决方案--------------------
第一次执行的时候 脚本还没有生成。所以第二次的时候才能执行。
------解决方案--------------------
你换成客户端事件试一下。
TextBox7.Attributes.Add( "onchange ", "调用函数 ");