日期:2014-05-17  浏览次数:20444 次

.net 中的程序问题
具体问题是我想在 下面函数执行完毕后让 另一个textbox 获得焦点
protected void ddlTargetitemCode_SelectedIndexChanged(object sender, EventArgs e)
{
// 事案項目
if (!string.Empty.Equals(ddlTargetitemCode.SelectedItem.Value))
{
// 提案商品名、実績商品名
this.ddlProposalCommodityName.Enabled = true;
this.ddlActualCommodityName.Enabled = true;
// 提案商品名、実績商品名項目DDLの設定
SetTargetCommodityToDropDownListByItemCode(this.ddlProposalCommodityName, true, ddlTargetitemCode.SelectedItem.Value);
SetTargetCommodityToDropDownListByItemCode(this.ddlActualCommodityName, true, ddlTargetitemCode.SelectedItem.Value);

// 事案項目選択時に、アクションプランを取得
DataSet ds = this.GetDsTargetItemMng();
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
DataRow dr = ds.Tables[0].Rows[0];
//アクションプラン
this.tbxActionPlan1.Text = dr["ActionPlan1"].ToString();
this.tbxActionPlan2.Text = dr["ActionPlan2"].ToString();
this.tbxActionPlan3.Text = dr["ActionPlan3"].ToString();
this.tbxActionPlan4.Text = dr["ActionPlan4"].ToString();
this.tbxActionPlan5.Text = dr["ActionPlan5"].ToString();
}
else
{
//アクションプラン
this.tbxActionPlan1.Text = "";
this.tbxActionPlan2.Text = "";
this.tbxActionPlan3.Text = "";
this.tbxActionPlan4.Text = "";
this.tbxActionPlan5.Text = "";
}
}
else
{
// 提案商品名、実績商品名
this.ddlProposalCommodityName.SelectedIndex = 0;
this.ddlActualCommodityName.SelectedIndex = 0;
this.ddlProposalCommodityName.Enabled = false;
this.ddlActualCommodityName.Enabled = false;
//アクションプラン
this.tbxActionPlan1.Text = "";
this.tbxActionPlan2.Text = "";
this.tbxActionPlan3.Text = "";
this.tbxActionPlan4.Text = "";
this.tbxActionPlan5.Text = "";
}
//((LinkButton)e.Item.FindControl("ddlTargetitemCode")).Attributes["onBlur"]= "tbxTitle.focus()";
tbxTitle.Focus();
}
}
#endregion 事案項目DDL変更時処理



以上为函数的整个代码  
  出现的问题是: 当把变红的地方加上断点进行调试运行时tbxTitle 这个文本框可以获取焦点
  当不加断点直接运行程序时文本框不能获取焦点
请各位大侠帮帮忙!!!

------解决方案--------------------
不调试运行焦点跑哪去了?没道理调试就可以 不调试就不行了
------解决方案--------------------
继续调到头继续走,肯定又个地方取消焦点的
------解决方案--------------------
探讨

继续调到头继续走,肯定又个地方取消焦点的

------解决方案--------------------
你断点后面的程序呢?完成这个过程就不再执行任何程序了吗?肯定是后面的程序把焦点给移走了

要不你重启一下电脑? 。net经常这样。
------解决方案--------------------
檢查下是否忘了
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//
}
}