protected override void RenderContents(HtmlTextWriter writer)
        {
            try
            {
                DumpCultures(writer, "RenderContents");
                //Render Assignment List webpart
                RenderAssignmentList(writer);
            }
            catch (System.Threading.ThreadAbortException)
            {
                // Not much we can do about this.
            }
            catch (SafeToDisplayException e)
            {
                SlkError slkError = new SlkError(ErrorType.Error, Constants.Space + e.Message);
                ErrorBanner.RenderErrorItems(writer, slkError);
            }
            catch (UserNotFoundException e)
            {
                SlkError slkError = new SlkError(ErrorType.Info, Constants.Space + e.Message);
                ErrorBanner.RenderErrorItems(writer, slkError);
            }
            catch (SqlException e)
            {
                ISlkStore store = null;
                try
                {
                    store = SlkStore;
                }
                catch (Exception)
                {
                }

                SlkError slkError = SlkError.WriteException(store, e);
                ErrorBanner.RenderErrorItems(writer, slkError);
            }
            catch (Exception ex)
            {
                ISlkStore store = null;
                try
                {
                    store = SlkStore;
                }
                catch (Exception)
                {
                }

                SlkError slkError = SlkError.WriteException(store, ex);
                ErrorBanner.RenderErrorItems(writer, slkError);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // render the HTML for the page
                using (HtmlTextWriter hw = new HtmlTextWriter(Response.Output, "  "))
                {
                    // render the "<html>" element and its contents
                    using (new HtmlBlock(HtmlTextWriterTag.Html, 0, hw))
                    {
                        RenderHead(hw);
                        try
                        {
                            string querySetName = QueryString.ParseString(QueryStringKeys.QuerySet);

                            // set <querySetDef> to the QuerySetDefinition named <querySetName>
                            QuerySetDefinition querySetDef = SlkStore.Settings.FindQuerySetDefinition(querySetName, true);
                            if (querySetDef == null)
                            {
                                throw new SafeToDisplayException(PageCulture.Resources.AlwpQuerySetNotFound, querySetName);
                            }

                            // render the "<body>" element and its contents
                            //hw.AddAttribute(HtmlTextWriterAttribute.Style, "overflow: hidden;");
                            hw.AddAttribute(HtmlTextWriterAttribute.Style, "width: 100%; overflow-y: auto;");
                            hw.AddAttribute(HtmlTextWriterAttribute.Id, "SlkAlwpQuerySet");
                            hw.AddAttribute(HtmlTextWriterAttribute.Onclick, string.Empty);
                            using (new HtmlBlock(HtmlTextWriterTag.Body, 0, hw))
                            {
                                AssignmentListWebPart.DumpCultures(hw, "Page_Load");
                                // begin the query set
                                hw.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
                                hw.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
                                hw.AddAttribute(HtmlTextWriterAttribute.Border, "0");
                                hw.AddAttribute(HtmlTextWriterAttribute.Class, "ms-toolbar");
                                hw.AddAttribute(HtmlTextWriterAttribute.Style, "border: none; background-image: none; width:100%; height:100%;");
                                hw.AddAttribute(HtmlTextWriterAttribute.Onclick, string.Empty);
                                using (new HtmlBlock(HtmlTextWriterTag.Table, 1, hw))
                                {
                                    RenderQueryLines(hw, querySetDef);
                                    RenderQuerySummary(hw, querySetDef);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            SlkError slkError;
                            //Handles SqlException separately to capture the deadlock
                            //and treat it differently
                            SqlException sqlEx = ex as SqlException;
                            if (sqlEx != null)
                            {
                                slkError = WebParts.ErrorBanner.WriteException(SlkStore, sqlEx);
                            }
                            else
                            {
                                slkError = SlkError.WriteException(SlkStore, ex);
                            }

                            WebParts.ErrorBanner.RenderErrorItems(hw, slkError);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                String queryCount = String.Empty;
                // render the HTML for the page
                using (HtmlTextWriter hw = new HtmlTextWriter(Response.Output, "  "))
                {
                    // render the "<html>" element and its contents
                    using (new HtmlBlock(HtmlTextWriterTag.Html, 0, hw))
                    {
                        // render the "<head>" element and its contents
                        using (new HtmlBlock(HtmlTextWriterTag.Head, 1, hw))
                        {
                            // create a link to "core.css";
                            // "/_layouts/1033/styles/core.css" except with "1033" replaced with the
                            // current SPWeb language code
                            // Include 1033 one as a back up
                            AddCoreCss(hw, 1033);
                            SlkCulture culture = new SlkCulture(SPWeb);
                            AddCoreCss(hw, culture.Culture.LCID);

#if SP2007
                            //Adds the Theme Css Url to Enable Theming in the frame.
                            hw.AddAttribute(HtmlTextWriterAttribute.Rel, "stylesheet");
                            hw.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
                            hw.AddAttribute(HtmlTextWriterAttribute.Href, SPWeb.ThemeCssUrl);
                            HtmlBlock.WriteFullTag(HtmlTextWriterTag.Link, 0, hw);
#endif

                            // create a link to ALWP's "Styles.css"
                            hw.AddAttribute(HtmlTextWriterAttribute.Rel, "stylesheet");
                            hw.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
                            hw.AddAttribute(HtmlTextWriterAttribute.Href, "Include/Styles.css");
                            HtmlBlock.WriteFullTag(HtmlTextWriterTag.Link, 0, hw);
                        }

                        // render the "<body>" element and its contents
                        hw.AddAttribute(HtmlTextWriterAttribute.Style, "width: 100%; overflow-y: auto; overflow-x: auto;");

                        using (new HtmlBlock(HtmlTextWriterTag.Body, 0, hw))
                        {
                            Microsoft.SharePointLearningKit.WebParts.AssignmentListWebPart.DumpCultures(hw, "Page_Load");
                            // render the outer table -- this contains only one row and one column, which
                            // in turn contains the entire query results table
                            hw.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
                            hw.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
                            hw.AddAttribute(HtmlTextWriterAttribute.Style, "width:100%;");
                            hw.AddAttribute(HtmlTextWriterAttribute.Border, "0");

                            RenderForm(hw);
                            RenderSortFunction(hw);

                            using (new HtmlBlock(HtmlTextWriterTag.Table, 0, hw))
                            {
                                // render the single row and column of the outer table
                                using (new HtmlBlock(HtmlTextWriterTag.Tr, 0, hw))
                                {
                                    using (new HtmlBlock(HtmlTextWriterTag.Td, 0, hw))
                                    {
                                        hw.WriteLine();

                                        try
                                        {
                                            // set <queryDef> to the QueryDefinition named <queryName>
                                            QueryDefinition queryDef = null;
                                            if (Query != null)
                                            {
                                                queryDef = SlkStore.Settings.FindQueryDefinition(Query);
                                            }

                                            if (queryDef == null)
                                            {
                                                throw new SafeToDisplayException(PageCulture.Resources.AlwpQuerySetNotFound, Query);
                                            }


                                            List <RenderedCell[]> renderedRows = PerformQuery(queryDef);

                                            //Set the QueryCount
                                            queryCount = renderedRows.Count.ToString(CultureInfo.InvariantCulture);
                                            //Renders the Result
                                            RenderQueryResults(queryDef, renderedRows, hw);
                                        }
                                        catch (Exception ex)
                                        {
                                            queryCount = PageCulture.Resources.AlwpQueryResultError;
                                            SlkError slkError;
                                            //Handles SqlException separate to capture the deadlock
                                            //and treat it differently
                                            SqlException sqlEx = ex as SqlException;
                                            if (sqlEx != null)
                                            {
                                                slkError = WebParts.ErrorBanner.WriteException(SlkStore, sqlEx);
                                            }
                                            else
                                            {
                                                slkError = SlkError.WriteException(SlkStore, ex);
                                            }

                                            WebParts.ErrorBanner.RenderErrorItems(hw, slkError);
                                        }
                                        finally
                                        {
                                            //Renders the JavaScript to set the Query Count.
                                            RenderQueryCount(queryCount);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }