Thursday 10 July 2014

largest-collection-of-free-microsoft-ebooks

Largest collection of FREE Microsoft eBooks ever, including: Windows 8.1, Windows 8, Windows 7, Office 2013, Office 365, Office 2010, SharePoint 2013, Dynamics CRM, PowerShell, Exchange Server, Lync 2013, System Center, Azure, Cloud, SQL Server, and much more.

These eBooks are available for download here:
 http://blogs.msdn.com/b/mssmallbiz/archive/2014/07/07/largest-collection-of-free-microsoft-ebooks-ever-including-windows-8-1-windows-8-windows-7-office-2013-office-365-office-2010-sharepoint-2013-dynamics-crm-powershell-exchange-server-lync-2013-system-center-azure-cloud-sql.aspx

Wednesday 11 June 2014

Show an Alert Message if no file was uploaded in RadfileExplorer Upload Popup

We may have scenario like to validate if no file was uploaded in Rad upload of rad file explorer
For this first write an javascript function like this in design page:
function OnClientLoad(explorer, args) {
//Find upload button and attach an event handler
                var uploadButton = $find("<%=RadFileExplorer1.ClientID%>" +"_btnUpload");
                uploadButton.add_clicked(function()
                {
                    var upload = $find('<%=RadFileExplorer1.Upload.ClientID %>');
                    var inputs = upload.getFileInputs();
                    var count = 0;
                    for (var i = 0 ; i < inputs.length; i++) {
                        if (inputs[i].value.length != 0) {
                            count++;
                        }
                    }
                    if(count == 0)
                        alert('Please select one file to upload.');
                })
            }
And add this function in RadfileExplorer client load event like

<telerik:RadFileExplorer runat="server" ID="RadFileExplorer1" OnClientLoad="OnClientLoad"  </telerik:RadFileExplorer>

Monday 9 June 2014

Partial Page Refresh after Download of file or using of Response.end in aspx page using iframe

Initially Declare a generic Handler like this
    public class Handler1 : IHttpHandler
    {

        #region IHttpHandler Members

        private HttpContext _context;
        private HttpContext Context
        {
            get
            {
                return _context;
            }
            set
            {
                _context = value;
            }
        }


        public void ProcessRequest(HttpContext context)
        {
            Context = context;
            string filePath = context.Request.QueryString["path"];
            filePath = context.Server.MapPath(filePath);

            if (filePath == null)
            {
                return;
            }

            System.IO.StreamReader streamReader = new System.IO.StreamReader(filePath);
            System.IO.BinaryReader br = new System.IO.BinaryReader(streamReader.BaseStream);

            byte[] bytes = new byte[streamReader.BaseStream.Length];

            br.Read(bytes, 0, (int)streamReader.BaseStream.Length);

            if (bytes == null)
            {
                return;
            }

            streamReader.Close();
            br.Close();
            string extension = System.IO.Path.GetExtension(filePath);
            string fileName = System.IO.Path.GetFileName(filePath);
            WriteFile(bytes, fileName, "application/" + extension, context.Response);
        }

        /// <summary>
        /// Sends a byte array to the client
        /// </summary>
        /// <param name="content">binary file content</param>
        /// <param name="fileName">the filename to be sent to the client</param>
        /// <param name="contentType">the file content type</param>
        private void WriteFile(byte[] content, string fileName, string contentType, HttpResponse response)
        {
            response.Buffer = true;
            response.Clear();
            response.ContentType = contentType;
            response.AddHeader("content-disposition", "attachment; filename=" + fileName);
            response.BinaryWrite(content);
            response.Flush();
            response.End();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        #endregion
    }
}

Next declare an iframe in aspx page (design)
<iframe id="iframe1 " style="display: none" runat="server" ></iframe>
and an update panel
<asp:UpdatePanel ID="UpdatePanel1 " runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
//controls design goes here
//Lets assusme we have a GridView1 here
</ContentTemplate>
</asp:UpdatePanel>
Next in aspx codebehind file write code as follows:
Some EventHandler()
{
//Method to bind GridView1 data
UpdatePanel1.Update();
   string path="Handler1.ashx?path=" + "declare your path here";
    iframe1.Attributes["src"] = path;
}
We are done:
Now we can see the page is partially refreshed when we called that event.




Wednesday 4 June 2014

Disable the text in Rad FileExplore Upload Popup

To disable the text in Rad FileExplore Upload Popup
Add the following Property in  onclientLoad = "OnClientLoad" on rad file explorer Property on design file
Next Add following java script :
function OnClientLoad (explorer, args) {
                $telerik.$(".ruFakeInput").attr("disabled", "disabled");
}
But this will disable the initial items only so if client clicks on Add button we need to disable them also
So add following java script like
function OnClientAdded(upload, args) {
                $telerik.$(".ruFakeInput").attr("disabled", "disabled");
            }

Next Add line like RadFileExplorer1.Upload.OnClientAdded = "OnClientAdded"; in Page load event of code behing file
We are done and disabled the text entering in Rad FileExplorer Upload Popup.


Thursday 3 April 2014

Close the radwindow from childpage without refreshing parentpage through javascript

In parent page design

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function onClientClose(oWnd, args) {
                // get the transferred arguments
                var arg = args.get_argument();
                if (arg == '' || arg == null) {
                }
                else {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest(arg);
                }
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" >
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="panel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="panel1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
<asp:Panel ID="panel1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button"  OnClick="Button1_Click"/>
 <telerik:RadWindow ID="Example" runat="server" Modal="True"  Title="example" OnClientClose="onClientClose">
        </telerik:RadWindow>
</asp:panel>


In parent page code behind


protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
       //Get Argument from childpage(popup)
            var result = e.Argument;
        }

 protected void Button1_Click(object sender, EventArgs e)
        {
           example.navigateurl="childpage.aspx";
        }


In child page design

<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;
        }

     

        function onClientClose(arg) {
            // Pass the arguments from the dialog to the callback function on the main page.   
            getRadWindow().close(arg);
        }

    </script>

In child page code behind

string samplevariable="test";

//Place this code to pass samplevariable to parentpage without refreshing it

Page.ClientScript.RegisterStartupScript(typeof(Page), "CloseScript_" + UniqueID, "onClientClose('" + samplevariable + "');", true);


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");