Posts

Showing posts from September, 2015

ASP.NET: Confirm PostBack OnClientClick Button

ASP.Net Button: <asp:Button ID="btnSubmit" runat="server" class="unrulyBtn" Text="Submit" OnClientClick="if ( ! btnSubmitonClickEvent()) return false;" OnClick="btnSubmit_Click" CausesValidation="True" /> Java Script Method: function btnSubmitonClickEvent() {         if (confirm('Once submitted, Flight Report for this sector cannot be edited.')) {          // We can't use disable here because if we make that button as disabled, In that case OnClick will not work.          // $('[id$=btnSubmit]').attr("disabled", "disabled");                          $('[id$=btnSubmit]').attr("style", "display:none");             return true;         }         else {             //   $('[id$=btnSubmit]').removeAttr('disabled');             $('[id$=btnSubmit]').attr("style", "display:block");        

SharePoint 2013: Working with User Profiles using CSOM

As we all know SharePoint 2013 provides strong support to client api. In this post we will talk about access user profile properties using client api. So now in SharePoint 2013 we can directly query to user profile and get all the user profile properties what we required. References which we need to provide <script src="/_layouts/15/jquery-1.9.0.min.js"></script> < script   src = "/_layouts/15/SP.Runtime.js" ></ script > <script src="/_layouts/15/SP.js"></script> <script src="/_layouts/15/SP.UserProfiles.js"></script> 1. Get User Profile Properties for Current User        $(document).ready(function(){        // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs. SP.SOD.executeOrDelayUntilScriptLoaded(loadUserData, 'SP.UserProfiles.js'); }); var userProfileProperties; function loadUserData(){ //Get Current Context v

C# Copy files from one server to another

Sometimes we need to copy files from one sever and paste those files to another server programmatically. So for that we can use below code but we should have admin credentials of that server where we want to paste files. In below method we need to pass source path of the server, from where we want to copy and destination path of the server, where we want to paste. Also we need to provide UserName, Domain, Password of the server where we want to paste those files. public void CopyFiles(string sourcePath, string destinationPath)         {             try             {                  IntPtr admin_token = new IntPtr();                 // use LOGON32_LOGON_NEW_CREDENTIALS as LogonType                 if (LogonUser(" UserName ", " Domain ", " Password ", 9, 0, ref admin_token) != 0)                 {                     WindowsIdentity wid_admin = new WindowsIdentity(admin_token);                     WindowsImpersonationContext wic =