How to show the every record updation status in UI?

2 posts, 0 answers
  1. keerthivasan
    keerthivasan avatar
    7 posts
    Member since:
    May 2015

    Posted 25 Oct Link to this post

    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)
            {
     
            }
    }
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 26 Oct Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top