protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         //string languageParam = Strings.Clean(Request.QueryString["language"]);
         string languageParam = ""; // disable langauge selection by query parameter
         string pageTitle     = "";
         string buttonText    = "";
         string language      = "";
         string reDirect      = "";
         MobileTermDictionary.DetermineLanguage(languageParam, out language, out pageTitle, out buttonText, out reDirect);
         litSearchBlock.Text = MobileTermDictionary.SearchBlock(MobileTermDictionary.RawUrlClean(Page.Request.RawUrl), "", language, pageTitle, buttonText, false);
         litAZList.Text      = MobileTermDictionary.AZBlock(MobileTermDictionary.RawUrlClean(Page.Request.RawUrl), language);
     }
     catch (Exception ex)
     {
         log.Error(ex);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            // Dictionary query parameters
            string expandParam = Strings.Clean(Request.QueryString["expand"]);
            //string languageParam = Strings.Clean(Request.QueryString["language"]);
            string languageParam = ""; //disable language selection by query parameter

            _searchStr = Strings.Clean(Request.QueryString["search"]);
            if (!String.IsNullOrEmpty(_searchStr))
            {
                _searchStr = _searchStr.Replace("[", "[[]");
            }

            //FOR TESTING !!@!!!
            _searchStr        = "can";
            litSearchStr.Text = "can";

            // Pager query parameter variables
            _currentPage    = Strings.ToInt(Request.Params["PageNum"], 1);
            _recordsPerPage = Strings.ToInt(Request.Params["RecordsPerPage"], 10);
            _offSet         = Strings.ToInt(Request.Params["OffSet"], 0);

            //Determine Language - set language related values
            string pageTitle;
            string buttonText;
            string language;
            string reDirect;

            MobileTermDictionary.DetermineLanguage(languageParam, out language, out pageTitle, out buttonText, out reDirect);
            _language = language;

            _dictionaryURL      = PageAssemblyContext.Current.PageAssemblyInstruction.GetUrl("CurrentUrl").ToString();
            litPageUrl.Text     = _dictionaryURL;
            litSearchBlock.Text = MobileTermDictionary.SearchBlock(_dictionaryURL, SearchString, language, pageTitle, buttonText, true);


            //TermDictionaryCollection dataCollection = null;
            //if (!String.IsNullOrEmpty(SearchString)) // SearchString provided, do a term search
            //{
            //    PageAssemblyContext.Current.PageAssemblyInstruction.AddUrlFilter(PageAssemblyInstructionUrls.AltLanguage, (name, url) =>
            //    {
            //        url.QueryParameters.Add("search", SearchString);
            //    });
            //    PageAssemblyContext.Current.PageAssemblyInstruction.AddUrlFilter("CurrentUrl", (name, url) =>
            //    {
            //        url.QueryParameters.Add("search", SearchString);
            //    });

            //    dataCollection = TermDictionaryManager.GetTermDictionaryList(language, SearchString, false, pager_RowsPerPage, _currentPage, ref pager_MaxRows);
            //}
            //else if (!String.IsNullOrEmpty(expandParam)) // A-Z expand provided - do an A-Z search
            //{
            //    _showDefinition = false;
            //    _expand = true;
            //    _expandText = expandParam;
            //    if (_expandText == "#")
            //    {
            //        _expandText = "[0-9]";
            //    }

            //    PageAssemblyContext.Current.PageAssemblyInstruction.AddUrlFilter(PageAssemblyInstructionUrls.AltLanguage, (name, url) =>
            //    {
            //        url.QueryParameters.Add("expand", _expandText);
            //    });
            //    PageAssemblyContext.Current.PageAssemblyInstruction.AddUrlFilter("CurrentUrl", (name, url) =>
            //    {
            //        url.QueryParameters.Add("expand", _expandText);
            //    });

            //    dataCollection = TermDictionaryManager.GetTermDictionaryList(language, _expandText.Trim().ToUpper(), false, pager_RowsPerPage, _currentPage, ref pager_MaxRows);
            //}

            //if (dataCollection != null)
            //{
            //    if (dataCollection.Count == 1 && !Expand) //if there is only 1 record - go directly to definition view
            //    {
            //        //string itemDefinitionUrl = DictionaryURL + "?cdrid=" + dataCollection[0].GlossaryTermID + "&language=" + Language;
            //        string itemDefinitionUrl = DictionaryURL + "?cdrid=" + dataCollection[0].GlossaryTermID;
            //        Page.Response.Redirect(itemDefinitionUrl);
            //    }
            //    else // bind results
            //    {
            //        //Load first rows

            //    }

            //}
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string startingUrl = "";

            try
            {
                startingUrl = PageAssemblyContext.Current.PageAssemblyInstruction.GetUrl("CurrentUrl").ToString();
                string cdrId         = Strings.Clean(Request.QueryString["cdrid"]);
                string term          = Strings.Clean(Request.QueryString["term"]);
                string id            = Strings.Clean(Request.QueryString["id"]);
                string languageParam = Strings.Clean(Request.QueryString["language"]);

                if (String.IsNullOrEmpty(cdrId) && (!String.IsNullOrEmpty(id)))
                {
                    cdrId = id;
                }

                if (cdrId.Contains("CDR"))
                {
                    cdrId = cdrId.Replace("CDR", "");
                }

                // Determine langauge based PageAssemblyContext.Current.PageAssemblyInstruction.Language and
                // looking at a language query parameter - currently language selection by query parameter
                // is turned off
                string pageTitle;  // output parameter
                string buttonText; // output parameter
                string reDirect;   // output parameter
                MobileTermDictionary.DetermineLanguage(languageParam, out _language, out pageTitle, out buttonText, out reDirect);


                //if (!String.IsNullOrEmpty(reDirect))
                //{
                //    string reDirectUrl = "http://" + Page.Request.Url.Authority.ToString() + reDirect + "?cdrid=" + cdrId;
                //    Page.Response.Redirect(reDirectUrl);
                //}

                if (!String.IsNullOrEmpty(cdrId))
                {
                    _di = TermDictionaryManager.GetDefinitionByTermID(_language, cdrId, "", 1);
                    if (_di != null)
                    {
                        dissectMediaHTML(_di.MediaHTML);

                        // Setup Url Filters
                        PageAssemblyContext.Current.PageAssemblyInstruction.AddUrlFilter("CurrentUrl", (name, url) =>
                        {
                            url.QueryParameters.Add("cdrid", cdrId);
                        });

                        PageAssemblyContext.Current.PageAssemblyInstruction.AddUrlFilter(PageAssemblyInstructionUrls.AltLanguage, (name, url) =>
                        {
                            url.QueryParameters.Add("cdrid", cdrId);
                        });

                        PageAssemblyContext.Current.PageAssemblyInstruction.SetWebAnalytics(WebAnalyticsOptions.Events.event11, wbField =>
                        {
                            wbField.Value = "";
                        });

                        litPageUrl.Text     = startingUrl;
                        litSearchBlock.Text = MobileTermDictionary.SearchBlock(startingUrl, "", _language, pageTitle, buttonText, true);
                    }
                    else
                    {
                        Page.Response.Redirect(startingUrl); // if no data returned - redirect to base page
                    }
                }
            }
            catch (Exception ex)
            {
                CancerGovError.LogError("MobileTermDictionaryDefinitionView", 2, ex);
                Page.Response.Redirect(startingUrl); // if error - redirect to base page
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // Dictionary query parameters
            string expandParam = Strings.Clean(Request.QueryString["expand"], "A");
            //string languageParam = Strings.Clean(Request.QueryString["language"]);
            string languageParam = ""; //disable language selection by query parameter

            SearchString = Strings.Clean(Request.QueryString["search"]);
            //Create a safe search string to be passed to the URL
            string _safeSearchString = System.Web.HttpContext.Current.Server.UrlEncode(SearchString);

            _term    = Strings.Clean(Request.QueryString["term"]);
            _version = Strings.Clean(Request.QueryString["version"]);

            if (!String.IsNullOrEmpty(SearchString))
            {
                SearchString = SearchString.Replace("[", "[[]");
            }

            // Pager query parameter variables
            _currentPage    = Strings.ToInt(Request.Params["PageNum"], 1);
            _recordsPerPage = Strings.ToInt(Request.Params["RecordsPerPage"], 10);
            _offSet         = Strings.ToInt(Request.Params["OffSet"], 0);

            //Determine Language - set language related values
            string pageTitle;
            string buttonText;
            string language;
            string reDirect;

            MobileTermDictionary.DetermineLanguage(languageParam, out language, out pageTitle, out buttonText, out reDirect);
            _language = language;

            _dictionaryURL      = PageAssemblyContext.Current.PageAssemblyInstruction.GetUrl("CurrentUrl").ToString();
            litPageUrl.Text     = _dictionaryURL;
            litSearchBlock.Text = MobileTermDictionary.SearchBlock(_dictionaryURL, SearchString, language, pageTitle, buttonText, true);

            // Setup Pager variables
            int pager_StartRecord = 0;
            int pager_EndRecord   = 0;
            int pager_MaxRows     = 0;
            int pager_RowsPerPage = 10;

            TermDictionaryCollection dataCollection = null;

            if (!String.IsNullOrEmpty(SearchString)) // SearchString provided, do a term search
            {
                PageAssemblyContext.Current.PageAssemblyInstruction.AddUrlFilter(PageAssemblyInstructionUrls.AltLanguage, (name, url) =>
                {
                    url.QueryParameters.Add("search", _safeSearchString);
                });
                PageAssemblyContext.Current.PageAssemblyInstruction.AddUrlFilter("CurrentUrl", (name, url) =>
                {
                    url.QueryParameters.Add("search", _safeSearchString);
                });

                dataCollection = TermDictionaryManager.GetTermDictionaryList(language, SearchString, false, pager_RowsPerPage, _currentPage, ref pager_MaxRows);
            }
            else if (!String.IsNullOrEmpty(Term))
            {
                DisplayLanguage dl;
                if (Language.ToLower().Trim() == "spanish")
                {
                    dl = DisplayLanguage.Spanish;
                }
                else
                {
                    dl = DisplayLanguage.English;
                }

                TermDictionaryDataItem di = TermDictionaryManager.GetDefinitionByTermName(dl, Term, Version, 2);
                string itemDefinitionUrl  = DictionaryURL + "?cdrid=" + di.GlossaryTermID;
                Page.Response.Redirect(itemDefinitionUrl);
            }
            else if (!String.IsNullOrEmpty(expandParam)) // A-Z expand provided - do an A-Z search
            {
                _showDefinition = false;
                _expand         = true;
                if (expandParam.Length > 0)
                {
                    _expandText = expandParam.Substring(0, 1);
                    if (_expandText == "#")
                    {
                        _expandText = "[0-9]";
                    }
                }
                else
                {
                    _expandText = "";
                }

                PageAssemblyContext.Current.PageAssemblyInstruction.AddUrlFilter(PageAssemblyInstructionUrls.AltLanguage, (name, url) =>
                {
                    url.QueryParameters.Add("expand", _expandText);
                });
                PageAssemblyContext.Current.PageAssemblyInstruction.AddUrlFilter("CurrentUrl", (name, url) =>
                {
                    url.QueryParameters.Add("expand", _expandText);
                });

                dataCollection = TermDictionaryManager.GetTermDictionaryList(language, _expandText.Trim().ToUpper(), false, pager_RowsPerPage, _currentPage, ref pager_MaxRows);
            }

            if (dataCollection != null)
            {
                if (dataCollection.Count == 1 && !Expand) //if there is only 1 record - go directly to definition view
                {
                    //string itemDefinitionUrl = DictionaryURL + "?cdrid=" + dataCollection[0].GlossaryTermID + "&language=" + Language;
                    string itemDefinitionUrl = DictionaryURL + "?cdrid=" + dataCollection[0].GlossaryTermID;
                    Page.Response.Redirect(itemDefinitionUrl);
                }
                else // bind results
                {
                    resultListView.DataSource = dataCollection;
                    resultListView.DataBind();
                }

                SimplePager.GetFirstItemLastItem(_currentPage, pager_RowsPerPage, pager_MaxRows, out pager_StartRecord, out pager_EndRecord);
                spPager.RecordCount    = pager_MaxRows;
                spPager.RecordsPerPage = pager_RowsPerPage;
                spPager.CurrentPage    = _currentPage;
                if (Expand)
                {
                    spPager.BaseUrl = DictionaryURL + "?expand=" + _expandText;
                }
                else
                {
                    spPager.BaseUrl = DictionaryURL + "?search=" + _safeSearchString;
                }

                if (IsSpanish)
                {
                    spPager.PagerStyleSettings.NextPageText = "Siguiente >";
                    spPager.PagerStyleSettings.PrevPageText = "< Anterior";
                }
            }
        }