Thursday 27 March 2014

Remove items from one list based on another List

Remove items from one list based on second list which contains duplicates or same records in first list


 FirstList.RemoveAll(a => SecondList.Exists(b => b.Id == a.Id));

Remove QueryString from url and Setting the readonly Property as False

 //Remove QueryString  from url and Setting the readonly Property as False

using System.Reflection;

                    PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
                    isreadonly.SetValue(this.Request.QueryString, false, null);
                    this.Request.QueryString.Remove("Id");

Wednesday 19 March 2014

Refresh Parent Page and closing the Rad window using Customize Url

We may have scenarios like closing the rad window where the rad window will call different page and refresh the parent page with customized url after task is finished in rad window
In that case

First Add the following java script to the page where Rad window is navigated

 <script type="text/javascript">
        // Get Rad Window
        function getRadWindow() {
            var oWindow = null;
            if (window.radWindow)
                oWindow = window.radWindow;
            else if (window.frameElement.radWindow)
                oWindow = window.frameElement.radWindow;
            return oWindow;
        }

        // Redirect page to url
        function redirectParentPage(url) {
            getRadWindow().BrowserWindow.document.location.href = url;
        }
    </script>

Next in that page code behind file  Add the following logic to respect event handler

//Customized Url
 string url = "";
 Page.ClientScript.RegisterClientScriptBlock(GetType(), "CloseScript", "redirectParentPage('" + url + "')", true);

This is will redirect to the parent page and refresh it.