Monday, September 6, 2010

Display Javascript Popup with Server side code in sharepoint 2010

Simple add the below method in your code behind

public void Popup()
{
// Define the name and type of the client scripts on the page.
String csname1 = "PopupScript";

//String csname2 = "ButtonClickScript";
Type cstype = this.GetType();

// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;

// Check to see if the startup script is already registered.
if (!cs.IsStartupScriptRegistered(cstype, csname1))
{

String cstext1 = "alert('Common are u still copying ...!');";

cs.RegisterStartupScript(cstype, csname1, cstext1, true);
}

}

Enable anonymous access on a Sharepoint site

To perform this procedure, an administrator must have enabled anonymous access for the Web application. If they haven’t done so, the Anonymous Access option does not appear.
Open the site on which you want to enable anonymous access.
On the Site Actions menu , click Site Settings.
Note: On a site for which the Site Actions menu is customized, point to Site Settings, and then click the settings that you want to view.
On the Site Settings page, in the Users and Permissions column, click Advanced permissions.
On the Permissions page, on the Settings menu, click Anonymous Access.
On the Change Anonymous Access Settings page, select the parts of your Web site that you want anonymous users to access.

Thursday, September 2, 2010

Get the URL of a List in Sharepoint

This is a seemingly simple task – given a List or Library in SharePoint, how do I get it’s URL? The difficulty here is that a List has multiple URLs – one for each View on the list. We can get those URLs, but sometimes you really just want the URL to the list, without the /forms/something.aspx bit too.
For example, you might want http://server/siteCollection/site/lists/somelist . If you entered this URL, you’d be taken to the default View for the list, so you don’t really need the extra /forms/… bit to identify the list – that’s all about identifying the view.
Sadly, though, there is no SPList.Url property or equivalent on the SPList object. So, how can I get a list’s URL? Well, all Lists have a RootFolder. This folder has a URL, relative to the SPWeb it’s in.
 So, we can do something like this:
string url = web.Url + "/" + list.RootFolder.Url
Well, that’s great – but the result has the full path, including the server name. This can differ in SharePoint with alternate access mappings, so it can be useful to get the server relative url instead. This can be slightly more complicated:
string url = "http://server/subsite/Documents/";
using (SPSite site = new SPSite(url))
{
    using (SPWeb web = site.OpenWeb())
    {
        SPList list = web.GetList(url);
        string listurl = web.ServerRelativeUrl;
        if(listurl == "/") listurl = string.Empty;
        listurl = listurl + "/" + list.RootFolder.Url;
        Console.WriteLine(listurl);
    }
}
This should give use the server relative URL for the list. Note also the bit where we clear our variable if we are in the root site of the root site collection of a web application (e.g. http://server/ ) as this returns an SPWeb.ServerRelativeUrl of “/”

The Top Three hottest new majors for a career in technology.

The following is my list of the Top Three hottest academic areas for a future career in tech:
Data Mining/Machine Learning/AI/Natural Language Processing
All of these fields help us sift through and organize huge amounts of information or data. When you apply your knowledge in these areas to a challenging problem in the online space, you know that you are working at a scale that is just immense.  It’s much easier said than done.  If you have a passion for this area and have a technical background there are a multitude of open positions that might hold a long-term career for you.  With the move to the cloud and the sheer amount of information on the web, this area of expertise will continue to be in great demand. Microsoft has a great need for both people interested in the research space and the applied space which is very refreshing.
Business Intelligence/Competitive Intelligence
The ability to see trends, make sense of data to a business audience and help to understand your customers requires a special person. Someone with a mix of engineering, BI/CI experience and a business mindset can take this field to the next level. You will help increase any employer’s bottom line and be able to provide organized data that is extremely valuable to any business. You can help drive business decisions and help your internal audience understand what the data is telling or showing you.
Analytics/Statistics – specifically Web Analytics, A/B Testing and statistical analysis
All of these subjects are offshoots of traditional degrees in CS and mathematics. They all apply to the online world we live in and will also be in great demand as we continue to monetize the web. Retailers, web services, and advertisers will need people in these fields as they try to get the most for their advertising money. As we continue to see the dollar amounts spent for online advertising worldwide, these fields will be hot and we will see online advertising change over time as a result of these positions.
If these fields interest you and you want to find out what some of these jobs really entail, visit our website and search on the terms above to get a more detailed look at the positions. These fields are very HOT and looking long term, the demand will be just that much greater in these areas.

Wednesday, September 1, 2010

C# 3D Array

C# makes the distinction between jagged and multi-dimensional arrays. Elements of a multi-dimensional array are stored in a contiguous block in memory while elements of a jagged array are not. Java arrays are actually jagged arrays, while C# supports both and allows you to choose which one you want based on the syntax of your code. Note that multi-dimensional arrays are better (in most cases) than jagged arrays.
Using jagged arrays in C# is not as simple as in Java. It’s almost like the way we would implement it in C++. 
int[][] jaggedArray = new int[2][];
jaggedArray[0] = new int[4];
jaggedArray[1] = new int[3]; 
However, multi-dimensional arrays in C# are very simply to use. You can create a 3 dimensional array as follows:
int[,,] array3D = new int[x, y, z]; 
then access its elements at array3D[i][j][k].
Sample Code: 
static void Main(string[] args)
{
    //  Array 3 Dimensions    int x = 4, y = 5, z = 6;

    //  Array Iterators    int i, j, k;

    //  Allocate 3D Array    int[,,] array3D = new int[x, y, z];

    //  Access array elements    for (i = 0; i < x; i++)
    {
        Console.WriteLine(i);

        for (j = 0; j < y; j++)
        {
            Console.WriteLine();

            for (k = 0; k < z; k++)
            {
                array3D[i, j, k] = (i * y * z) + (j * z) + k;
                Console.Write("\t{0}", array3D[i, j, k]);
            }
        }

        Console.WriteLine('\n');
    }
}