Skip to main content

Posts

Showing posts from February, 2012

Default Databases Created in SQL Server After Sharepoint 2010 Installation

These are the databases that are created after sharepoint 2010 installation.

Content Query WebPart (CQWP) in SharePoint 2010

The Content Query Web Part is a tool that site designers can use to aggregate interesting and relevant slices of information on web page by letting you build queries through an easy to use UI and then display that content in unique, configurable ways. The CQWP is designed to return roll-up content over several different scopes, anywhere from a single a list or library, to all lists or libraries across an entire Site Collection.  In SharePoint 2010, the CQWP single list query is also optimized to work over large single libraries, taking advantage of smart indices and other tools designed to improve query performance over large document libraries. Content Query WebPart comes first in MOSS 2007, but in SharePoint 2010 there are some new features introduced.Content Query Web Part (CQWP) is used to show information from sites in the current site collection by querying, filtering, and sorting the content. Also CQWP you can show information from list as well as from publishi...

Passing value from popup window to parent form's TextBox Using JavaScript

Passing values from a popup window back to the parent page is an often asked question. Especially when there is a GridView type control in the popup. In the following example we will be using two forms. The parent form will be parent.aspx and the popup will be popup.aspx. Also note that the parent.aspx form is derived from some MasterPage. Code is provided both in VB.Net and C#.Net. --- .aspx of parent form --- <script type="text/javascript"> function OpenPopup() {     window.open("popup.aspx","List","scrollbars=no,resizable=no,width=400,height=280");     return false; } </script> .       . .       <asp:TextBox ID="txtPopupValue" runat="server" Width="327px"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Show List" /> --- .vb of parent.aspx if vb.net is the language --- If Not IsPostBack Then     Me.Butt...

To Prevent Browser BACK button click after SignOut Using JavaScript

There are so many threads open related to this issue. After sign out when the user press BACK button on the browser, it gets him to the members page. Logicaly, it's done on the client side and we cannot do much from the code-behind. So, in order to prevent Browser BACK button click after SignOut, we have to use some javascript. The first and easiest approach to acomplish this is by using the following javascript code: <body onload="javascript:window.history.forward(1);">  This code should be placed on the <body> tag of the Members page where Log out button appears. The problem is that this code will work perfectly on IE (Internet Explorer) but won't work at all for Mozilla Firefox 3.x versions. So, in order to make this work on Mozilla Firefox, I've prepared Javascript function which is: <script type="text/javascript" language="javascript">   function disableBackButton() { window.history.forward() }  d...

Dispaly the time on Webpage using Java Script

JavaScript sample to continuously display the current time on the web page. Continuously means that the textbox value will be updated with the current time every second. <script type="text/javascript">     function ShowTime() {         var dt = new Date();         document.getElementById("<%= TextBox1.ClientID %>").value = dt.toLocaleTimeString();         window.setTimeout("ShowTime()", 1000);     }   </script>  <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>  <script type="text/javascript">     // a startup script to put everything in motion     window.setTimeout("ShowTime()", 1000); </script> If you are using normal web form then it can also be called on Body onload event. If you are using MasterPage then it can be called within...

Select and Deselect All check boxes in a Grid Using JavaScript

Call the below function in the onclick event of the header check box. function  SelectDeselect(headerCheckBox) { //Get grid view object using grid view id. var  gridViewControl = document.getElementById( '<%=GridView1.ClientID %>' ); //Get all input tags from the grid view(i.e table). var  inputTagsFromGrid = gridViewControl.getElementsByTagName( "input" ); //Loop through each input tag and check the type and select or deselect the input field. for  (index = 0; index < inputTagsFromGrid.length; index++) { //Checking the type as check box or not. if  (inputTagsFromGrid[index].type ==  'checkbox' ) { //This will be selected or deselected based on the header checkbox selection. inputTagsFromGrid[index].checked = headerCheckBox.checked; } } }

Enabling anonymous access in SharePoint 2007

Even though Microsoft has done a great job on improving the user interface in SharePoint 2007, some things are still buried and require a little “black magic” to get done. In this entry I’ll show you how to enable anonymous access on your site. First, you need to enable anonymous on the IIS web site (called a Web Application in SharePoint land). This can be done by: •Launching Internet Information Services Manager from the Start -> Administration Tools menu •Select the web site, right click and select Properties •Click on the Directory Security tab •Click on Edit in the Authentication and access control section Instead we’ll do it SharePoint style using the Central Administration section: •First get to your portal. Then under “My Links” look for “Central Administration” and select it. •In the Central Administration site select “Application Management” either in the Quick Launch or across the top tabs •Select “Authentication Providers” in the “Application Security” section...

Set Focus Controls - AutoPostBack = true Using Java Script

Every time user’s complaints me about page scroll issues.  For example: If a lengthy page having a dropdown list with AutoPostBack = true at bottom of page. After the selection page gets reloaded and focus will be on top of the page. User needs to again scroll down the page for next key in. Here a sample solution for help...  c# public void SetFocus(Page sPage)     {         string[] sCtrl = null;         string sCtrlId = null;         Control sCtrlFound = default(Control);         string sCtrlClientId = null;         string sScript = null;         sCtrl = sPage.Request.Form.GetValues("__EVENTTARGET");         if ((sCtrl != null))         {      ...

Redirect to a new page, when we get 404.htm error page in the application

Create a custom Page Not Found is to create a site level feature receiver that will attach it to the webApplication instance. On the activated event you would attach it like this:     [SharePointPermission(SecurityAction.LinkDemand, ObjectModel = true)]     public override void FeatureActivated(SPFeatureReceiverProperties properties)     {       if (properties != null)       {         try         {           SPSite site = properties.Feature.Parent as SPSite;           System.Uri webApplicationUri = new Uri(site.Url);           SPWebApplication webApplication = SPWebApplication.Lookup(webApplicationUri);           if (webApplication != null) ...

Sharepoint Programming Part7

Q) Retrieving information from linked lists in SharePoint using LINQ to SharePoint? using System.Linq; using Microsoft.SharePoint; using Microsoft.SharePoint.Linq; In the Page_Load method, add the following code: DataContext dc = new DataContext(SPContext.Current.Web.Url); var customers = dc.GetList < Customer > (“Customers”); var customerDataSource = from customer in customers select new {CustomerName = customer.Title, ContactLastName = customer.PrimaryContact.Title, ContactFirstName = customer.PrimaryContact. FirstName}; CustomerGridView.DataSource = customerDataSource; CustomerGridView.DataBind() Q) How you can retrieve the name of each folder in the top - level site of a site collection, as well as the number of subfolders that each folder contains? using System; using System.Text; using Microsoft.SharePoint; namespace Wrox.SixInOne { class Program { static void Main(string[] args) { StringBuilder folderName = new StringBuilder(); ...

How to Send Email to Registered Users

 I need to send an email to registered user for every 3 days.Mail starting date will be read from database(sqlserver).This should be done automatically. I am hosting my website on shared webserver like india.com. Think I cannot write windows service and install. I think we need to wrtie webservice which fires acynchronously which checks date. am n confusion.please guide me. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net; using System.Net.Mail; using System.Configuration; using System.Data; using System.Web.Security; namespace IATI_Email_Application {    public partial class ATIEmail : System.Web.UI.Page    {        protected void SUBMIT_Click(object sender, EventArgs e)        {            String SMTPServerName = ConfigurationManager.AppSettings["SMTP_SERVER"]...

Insert Data Into Sharepoint List Using C# Code

using System; using System.Runtime.InteropServices; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Serialization; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using Microsoft.SharePoint.WebPartPages; namespace insertdataintocustomlist {     [Guid("8470d1da-6e24-479c-b0e8-102f82a41a68")]     public class insertdatademo : System.Web.UI.WebControls.WebParts.WebPart     {         public TextBox oTextTitle;         public TextBox oTextEmployeeName;       //public TextBox oTextEmployeeID;         public TextBox oTextEmployeeLocation;         public TextBox oTextEmployeeDesignation;         public TextBox oTextEmployeeDateOfJoin;         public Label oLabelMessage;         public Button oButtonSubmi...

Concated the two Sharepoint Lists Using Event handlers

public override void ItemAdding(SPItemEventProperties properties)         {             SPListItem sp = properties.ListItem;             String strg = (String)sp["Order Num"];             String strng = (String)sp["Order Date"];             sp["Order Name"] = strg + strng;          } or  public override void ItemAdding(SPItemEventProperties properties)         {             if (properties.ListTitle == "orders")             {                 string str;                 str = properties.AfterProperties["order_x0020_no"].ToString();                 str = str + properties.AfterProperties["order_x0020_date"...

Upload the Files in Sharepoint Using C#

public class insertdatademo : System.Web.UI.WebControls.WebParts.WebPart { public FileUpload file;  }  public insertdatademo()         {                       file=new FileUpload();         } protected override void CreateChildControls() { file=new FileUpload();             file.DataBind();              this.Controls.Add(file);             oButtonSubmit.Click += new EventHandler(oButtonSubmit_Click); }  void oButtonSubmit_Click(object sender, EventArgs e) { if(file.HasFile==true)                 {                     SPAttachmentCollection attach = myListItem.Attachments;                     String fileName = file.Pos...

How to Use TLS with SMTP to Secure Your Email

Many of us Microsoft Exchange Server administrators have learned to ignore a simple fact: Most email is easily read in transit. You've no doubt heard the chestnut that sending SMTP email is equivalent to sending a postcard; anyone who can access the postcard can read its contents (thus leading to fascinating historical artifacts such as the  stamp code for concealing amorous messages  in plain sight). How did this insecure transport method come about? The engineers who originally designed SMTP were working from a very different set of assumptions about how email would be used, who would use it, and how the Internet would be operated and maintained. Various proposals have been offered to update the security of SMTP traffic by changing, extending, or even replacing basic SMTP to provide authentication, nonrepudiation, and confidentiality. However, SMTP deployment worldwide has reached critical mass; it's very unlikely that the protocol itself will be superseded by somethi...

Creating SharePoint 2010 Workflows: Starting with Visual Studio 2010 Part 3

Creating SharePoint 2010 Workflows: Starting with Visual Studio 2010 Part 1 Creating SharePoint 2010 Workflows: Starting with Visual Studio 2010 Part 2 Go to the Expense Reports list. Select the expense report that you created earlier, and then click the Workflows button on the SharePoint Ribbon, as Figure 23 shows. The  Start a New Workflow  window, which Figure 24 shows, appears. Click the Workflow button to start our workflow. Go to the workflow status, and you should see the Hello World message, as Figure 25 shows. Figure 23: Choosing a workflow in the SharePoint Ribbon Figure 24: Starting a workflow Figure 25: Workflow outcome with Hello World Workflow Features Workflows that are generated from VS 2010 are logically packaged as site collection features. If the feature is not activated, then the workflow template cannot be used. Workflows that are generated by VS 2010 are compiled as .dll files that must be installed into the globa...