This is a migrated thread and some comments may be shown as answers.

How to show the every record updation status in UI?

1 Answer 80 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
keerthivasan
Top achievements
Rank 1
keerthivasan asked on 26 Oct 2016, 04:37 AM

In a loop, I Can update the status for every record. So i need to show the status of record after the every single record updated. These should done when the button is clicked.
When i click start button it should updated the every record status in loop. Then i need to show every record status for every updates in UI.

protected void btnstart_Click(object sender, EventArgs e)
    {
        string pageId = string.Empty;
        divMsg.Style.Add("display", "none");
        divMsg.Attributes.Add("class", "");
        try
        {
 
            DataSet DsPages = (DataSet)ViewState["SitePages"];
            bool IsSucess = false, IsError = false;
            string SqlQuery = string.Empty;
            if (DsPages.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < DsPages.Tables[0].Rows.Count; i++)
                {
                    try
                    {
                        htmlClean(DsPages.Tables[0].Rows[i]["contents"].ToString());
                        pageId = DsPages.Tables[0].Rows[i]["ID"].ToString();
                        SqlQuery = TransformXMLToHTML(htmldesign.InnerText, txtPageTypeXslt.InnerText.Trim());
                        SqlQuery = SqlQuery.Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>", "");
                        PagesBL objPage = new PagesBL(1);
                        if (!string.IsNullOrEmpty(SqlQuery))
                        {
                            if (objPage.ExecuteQuery(SqlQuery) > 0)
                            {
                                PagesBL objPageBL = new PagesBL();
                                objPageBL.UpdateLastExtract(DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss"), DsPages.Tables[0].Rows[i]["ID"].ToString());                               
                                IsSucess = true;
                            }
 
                        }
                    }
                    catch (Exception ex)
                    {
                        IsError = true;
                        string Error = ex.Message;
                        PagesBL objPageBL = new PagesBL();
                        Errors objErr = new Errors();
                        objErr.PageID = pageId;
                        objErr.ErrorOccuredOn = DateTime.Now;
                        objErr.ErrorText = ex.Message;
                        objErr.SQLError = ex.Source == ".Net SqlClient Data Provider" ? SqlQuery : ex.Message;
                        objErr.ErrorStatus = 1; //1=
                        objPageBL.InsertErrors(objErr);
                        // divMsg.Attributes.Add("class", "alert alert-danger");
                        // divMsg.InnerText = "Extract process complete with few error.Please check the error list";
                    }
                }
                if (IsSucess && !IsError)
                {
                    Session["Complete"] = "True";
                    divMsg.Style.Add("display", "block");
                    divMsg.Attributes.Add("class", "alert alert-success");
                    divMsg.InnerText = "Extract process completed.";
                }
            }
        }
        catch (Exception ex)
        {
 
        }
}

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 26 Oct 2016, 06:41 AM

Hello,

The WebForms concept does not have a built-in feature for this, it operates primarily with synchronous server calls and the asynchronous calls (also known as AJAX requests) still wait for the entire server code to run and render the page before returning the needed pieces to the browser.

So, what you need is a way to send a response to the browser while the server code is running and I can suggest two ways of doing that:

  • use a tool like SignalR that can provide you with client-side events and information from arbitrary places in your server code
  • OR, create a web service that will be polled by the client on a preset interval (e.g., a second, a few seconds, that depends on you) and share information from the Page with the service so it can be downloaded on the client. RadProgressArea already does this, you can see RadProgressArea Overview live demo, and another similar example is available in the Track Long Running Server Operation with RadProgressBar code library entry.

Regards,

Marin Bratanov
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Tags
General Discussions
Asked by
keerthivasan
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or