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

asp.net弹出消息框后为什么会跳出循环

  string Wkid = Request.QueryString["id"];
  DateTime now = DateTime.Now;
  DateTime d1 = new DateTime(now.Year, now.Month, 1);
  int c = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
  for (int i = 0; i < c; i++)
  {
  string j = d1.AddDays(i).toFormatShortDate();

  ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.Page.GetType(), " btn_check", "alert ('这个月还没安排的日期:" + j + "');", true);

  }

------解决方案--------------------
探讨
string Wkid = Request.QueryString["id"];
DateTime now = DateTime.Now;
DateTime d1 = new DateTime(now.Year, now.Month, 1);
int c = DateTime.DaysInMonth(DateTime.Now.Y……

------解决方案--------------------
应该这样来做:
StringBuilder sb = new StringBuilder();
 for (int i = 0; i < c; i++)
{
string j = d1.AddDays(i).toFormatShortDate();

sb.Append("alert ('这个月还没安排的日期:" + j + "');"); 
}
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.Page.GetType(), " btn_check", sb.ToString(), true);

------解决方案--------------------
探讨

干嘛要跳出多次啊 循环玩跳出提示成功不就OK吗

ScriptManager.RegisterStartupScript 放循环外就行了