Showing posts from June, 2013

How to run SharePoint code with Elevated Privileges ?What are the security risks in it ?

SharePoint elevated privileges, site collection administrator code RunWithElevatedPrivileges is a class in SharePoint which comes under SPSecurity namespace. It allows developers to create the code that runs as the System Account instead of the logged in user, essentially giving that user Administrator Level Permissions in a specific space. So there is a question that, Run with elevated privileges can create high security risk ? Security risk is very minimal as the user will only have permission to do exactly what the developer will allow them through the code. Here is a syntax for that:  private void yourFunction()   {   // Non-Elevated Permission Code Goes Here  SPSecurity.RunWithElevatedPrivileges(delegate()   { // Elevated Permission Code Goes Here }); // Non-Elevated Permission Code Goes Here }

Upload images and show the list of image in gridview to code

Below code will upload image in a particular folder and will show the list of images from that folder. User may delete images from that list. HTML Code: <div>         <table style="width: 90%">             <tr>                 <td style="width: 50%">                     File Upload with Thumbnail Generator:<br />                     <asp:FileUpload ID="FileUpload1" runat="server" /><br />                     <asp:Button ID="buttonUpload" runat="server" Text="Upload" OnClick="buttonUpload_Click" /><br />                 </td>                 <td style="width: 50%">                     <asp:GridView ID="UploadedFiles" DataSource="<%# GetUploadList() %>" runat="server"                         CellPadding="4" ForeColor="#333333" GridLines="None" OnRowDele

Java Script Form Validation

Form validation is a process by which users are restrict to enter irrelevant data. For eg invalid format of email id, alphabets in mobile no.l field. Below is the code to validate a form. Below function can be call either on a button click or on an anchor link.   function Validation() {             var regexMobile = /^[7-9][0-9]{9}$/;             var regexNumberCount = /^\d{10}$/;             var regexpincode = /^[1-9][0-9]{5}$/;             var regexemailid = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;             var name = document.getElementById('<%=txtName.ClientID %>');             var mobile = document.getElementById('<%=txtMoile.ClientID %>');             var address = document.getElementById('<%=txtareaAddress.ClientID %>');             var email = document.getElementById('<%=txtEmail.ClientID %>');             var pincode = document.getElementById('<%=txtPincode.ClientID %>');      

Timer job in SharePoint 2010. How to create a timer job?

What is Timer Job in SharePoint - Timer Jobs are background processes that are managed by SharePoint. A timer job runs on a periodic basis defined in central admin. A timer job runs periodically, can be scheduled hourly, daily, weekly. Ex: User profile sync, Search Indexing

How to export subsites or list in sharepoint 2010?

Some times you need to take the backup of your subsites with all pages, list and library. Subsites can not be taken as backup and restore. Subsite can be exported and imported to another site. First you need to export the subsite. So to do that Go to central admin, Click on backup and restore, then "Export a site or list" as shown in below screen. Export subsite Then select your site collection, after that select your subsite and give a file name for ex- musubsiteexport. Leave other things as usual and click on start export and wait for completion. subiste, list sharepoint 2010