如何使用初始值呈现.aspx,但继续在后面的代码中运行条件语句并在完成后重定向?

时间:2022-02-22 21:40:44

Here is what I have...

这是我的......

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        if (Request.QueryString["Id"] != null)
        {
            int iID = Convert.ToInt32(Request.QueryString["Id"].ToString());
            WaitForRequest(iID);
        }
    }
}
public void WaitForRequest(int id)
{
    SqlParameter[] sqlParms = new SqlParameter[1];
    sqlParms[0] = new SqlParameter("@ID", id);
    int iStatus = Convert.ToInt32(DBManager.SqlHelper.ExecuteScalar(connString, CommandType.StoredProcedure, "[dbo].[Proc]", sqlParms).ToString());

    if (iStatus < 3)
    {
        do
        {
            tbLaunchStatus.Text = iStatus.ToString();

            Thread.Sleep(500);

            iStatus = Convert.ToInt16(DBManager.SqlHelper.ExecuteScalar(connString, CommandType.StoredProcedure, "[dbo].[Proc]", sqlParms).ToString());
        } while (iStatus < 3);
    }
}

Basically, upon redirecting to this page, I would like to render the page with the initial values, and continue to run the conditional do/while in the code behind until it returns a value that I am waiting for. Then it will redirect. Currently, the referring page is displayed until the conditional loop is met in this page, and then this page is displayed with the final values. I know there is AJAX stuff for this, but this is on an legacy program, and AJAX is not currently involved. Thoughts?

基本上,在重定向到这个页面时,我想用初始值渲染页面,并继续在后面的代码中运行条件do / while,直到它返回我正在等待的值。然后它将重定向。目前,显示引用页面,直到在此页面中满足条件循环,然后显示该页面的最终值。我知道这有AJAX的东西,但这是遗留程序,目前还没有参与AJAX。思考?

1 个解决方案

#1


0  

Directly, you need AJAX.

直接,你需要AJAX。

Without AJAX, you can split the logic in two parts. Make a function of the logic that you want to run in back ground. And when the page gets loaded, do a postback to that function via JS.

如果没有AJAX,您可以将逻辑拆分为两部分。创建您想要在后台运行的逻辑功能。当页面加载时,通过JS对该函数进行回发。

#1


0  

Directly, you need AJAX.

直接,你需要AJAX。

Without AJAX, you can split the logic in two parts. Make a function of the logic that you want to run in back ground. And when the page gets loaded, do a postback to that function via JS.

如果没有AJAX,您可以将逻辑拆分为两部分。创建您想要在后台运行的逻辑功能。当页面加载时,通过JS对该函数进行回发。