美好的一天这里的每一个人都是我的代码
if (type.Contains("Loan Date"))
{
prenda.LoanMonth = year.ToString() + "/" + month.ToString();
string a = servs.CheckLM(prenda);
if (Convert.ToInt32 (a) != 0)
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "key", "myFunction();", true);
//create a popup if yes process if no exit
//if yes
prenda.LoanMonth = year.ToString() + "/" + month.ToString();
servs.DeletePrendaLM(prenda);
foreach (DataRow row1 in table.Rows)
{
prenda.Bcode = row1["Bcode"].ToString();
prenda.Jprincipal = Convert.ToDecimal(row1["JPrincipal"].ToString());
prenda.Aprincipal = Convert.ToDecimal(row1["APrincipal"].ToString());
prenda.Cprincipal = Convert.ToDecimal(row1["CPrincipal"].ToString());
prenda.LoanMonth = year.ToString() + "/" + month.ToString();
user.UserID = Session["UserID"].ToString();
servs.UploadPrendaLM(prenda, user);
}
}
问题是,只要进程通过它就Page.ClientScript.RegisterStartupScript(Page.GetType(), "key", "myFunction();", true);
没有执行,它在完成按钮点击过程后执行 myFunction(),我不能在下面创建一个if子句因为它在我可以使用myFunction()之前首先完成所有过程我需要先执行该过程,然后再继续下面的步骤 //
答案 0 :(得分:1)
很少有可能有用的东西
RegisterStartupScript方法添加的脚本块在页面完成加载但在页面的OnLoad事件被引发之前执行。 >>你在哪里添加脚本(哪个事件?)在OnInit或init完成事件中尝试。
您可以通过IsStartupScriptRegistered方法(Page.ClientScript命名空间)检查是否添加了脚本