Visual Studio 2008 extension for SharePoint to be released in June 2008

Hi,

Today I have a very bad news for those who work on SharePoint 2007 and want to work with Visual studio 2008 and take advantage of the latest feature in JavaScript debugging etc. The visual Studio extension for SharePoint Visual studio 2008 is being planned to be released in June 2008. This is way far down the road then what I would have expected.

For current its best to forget about it and work on the Visual Studio 2005. For those of you who are thinking on working on SharePoint 2007 do not throw away your visual studio 2005 (after getting the multi targeting feature in VS 2008) for next 6 months or so.

 

Continued...

Less known important functionality of Request Object

Hi,

Today I was discussing with my friends about some of the cool stuff available in the request class but rarely used or talked. After the talk I discussed on posting them in the blog.

The first in the list is the Request.AcceptTypes. The property returns an array of all the mime types supported by the browser. The results were interesting for me. The number of mime type supported by IE7 are far more than Firefox. The extra mime types included in IE are image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword. This means that IE can easily recognize these file types and open them in correct application.

Continued...

C Sharp how to find if a given string is a number or not

Hi,

When using JavaScript many a times we have a requirement to find if a value is number or not. With JavaScript its pretty easy, as it gives us a function isNaN which tells us if the string is a number or not. But how can you tell in C# if a string is number or not?

When I confronted with the problem, one of the solution was to use the int.Parse() method inside a try catch block. Below is an example of what I meant

try

{ int.Parse("5000"); }

catch

{ }

Continued...

Creating a generic function to work on all the similar controls in a page using the delegate

Hi,

Of late I have found this one question related to finding controls inside the page dynamically and apply some similar function to them. Like put a css class to all the textbox (or for that matter any control) in a page. Remember a page can have textbox as a control directly under it, or the textbox can be inside another composite control (like login control, gridview, detailview) inside the page.

Many a times we do not want to do this work for individual control but rather have a function, which will do this for all the control in the page. This way it becomes more maintainable and easy to implement.

Continued...

Finding more about Asp.Net Environment using the GetEnvironmentVariables method of Environment class

Hi,

What do you do when you need to find the values of various environment variables in the system like USERDOMAIN, PROCESSOR_ARCHITECTURE, COMPUTERNAME, USERNAME, PROCESSOR_IDENTIFIER, etc. well with asp.net this can be a very simple Job. You can get all these value along with a set of other values with the help of

Environment.GetEnvironmentVariables().

The static function returs the IDictionary collection of the Envirement varibales. To view the value you need to know the key for each value. But its not always known to us.

So what you can do is bind the dictionary to a grid view and see all the keys and values avilable.

Continued...

Preventing one click attack on you site by using ViewStateUserKey

Hi,

One of the very rich security feature and also one of the least known is the ViewStateUserKey. The key is used to add an identifier to the individual user in the viewstate variable for the page.

The value of the variable needs to be set in the page’s init phase. If you try and set the value in page load then it will give an error. Normally the value will be set to a value which is unique to individual users. Setting a constant value for all the users is equivalent to keeping it null. Normally we can fill the value with the userId or sessionID. For many technical reasons it is best to use the sessionID for the same (SessionID are unique, varies from time to time and are different from individual users.).

Continued...

How to change the maximum number of character displayed in SQL server Query analyzer and Management studio

Hi,

One of the very simple and common that one of the commenter asked me a few days ago was why does the SQL query analyzer show only results unto 255 character only and not full column text. This is common to any data type in SQL server Query Analyzer.

The maximum number of character displayed using the tools->Option menu. Go to the result Tab and change the 'Maximum characters per column'. BY default the value is set to 255. The maximum value allowed here is 8192 character.

Continued...

Use SQL to find all the available SQL server in the network

Hi,

An interesting question asked to me by one of my colleague quite some days back. How do we find all the SQL server running in the network in SQL? Well the requirement was unique, but the way to do it is pretty simple.

All we need to do is use the XP_CMDShell stored procedure in the master database with a parameter 'OSQL -L'. So the full code for the same is

CREATE PROCEDURE dbo.ListOFLocalServer 
AS 
BEGIN 
 
CREATE TABLE #tempserverTable(servername VARCHAR(255)) 
 
INSERT #tempserverTable EXEC master..XP_CMDShell 'OSQL -L' 
 
DELETE # tempserverTable WHERE servername ='Servers:' 
 
SELECT LTRIM(servername) FROM #tempserverTable WHERE servername!= 'NULL' 
 
 DROP TABLE #tempserverTable
END

Continued...

Concatenating all the rows of a column using the coalesce function

Hi,

 

A few days ago one of my friend asked me about how to concatenate all the rows in a table or some of the rows in a table in a string in the SQL Server. The first idea was to create a user defined function, which would take the column name and return the concatenated value of all the rows in that column.

 

But a little later I found there is an inbuilt function in TSQL for the same. We can use the coalesce function to get the result of all the rows in a column in TSQL. Here is an example of the same

Continued...

Microsoft released the source code for Dot net Framework class library

Hi 

 

The news is out and so are the source codes of dot net framework. Microsoft has released the source code for dot net class library. This is one of the biggest news in the waiting for a long time.

 

Today ScottGu announced the release of the source code of dot net framework class library. The source are released and well integrated with the Visual studio 2008 and that even allows you to debug through the source code when you get stuck.

 

Continued...

Subkeys scope limitation of a cookie in Asp.Net

Hi,

In My last 2 posts I have talked about the overview of cookie and how to read and write with the help of a cookie. In this post I will talk about some of the more advanced work that can be done with cookie in Asp.Net.

Many a time we just don’t want to store some values in cookie but a collection of name value pair in a cookie. Remember that there are many limitations in number of cookies you should use. If we use more number of cookies in our application then the possibility of browser deleting the cookie will increase. Hence we should try and use less number of cookies and utilize a cookie to store maximum amount of data.

Continued...

Asp.net Reading and writing value in cookies

Hi,

In my last post I wrote about and overview of cookie, there basic use and some of their limitation. In this post I will talk on how do we read and write cookies with the help of Asp.Net.

When a browser makes a request to the server it also send existing (at the browser end) cookies information for that website. In Asp.Net the HttpRequest (also referred as Request property in the page class) objects contains a collection of all the cookies sent by the browser.

We can read the cookies from the request object like this.

if (Request.Cookies["lastVisit"] != null)

Continued...

Asp.net cookies an overview

Hi,

When working with a web application many a times we want to store the client specific data on the client side only. This helps in showing personalized data for the client. The session maintained by default is also done with the help of the session cookie only.

In a layman developer word a cookie is a small amount of data that is passed between the client and the server in the request and response. The data in the cookie can be read in interpreted by the server and is sent to the server whenever the user visits the same site.

But remember maintenance of cookie also depends on the user. Many user can turn there cookie off or the users can delete the cookies in there cookies. Moreover client can read the information kept in the cookie. That is why cookie cannot be used to store sensitive data.

Continued...

Dot Net Framework 3.5 Namespace poster available for download

Hi,

Here s something that I found very useful on the Dot net framework3.5.  If you have just started to learn about Dot net framework 3.5 and want to know all the changes in the name space and the new namespaces includes in the framework, below is the chart showing it.

The Dot net framework poster is also available in many formats. Below are the links for the same.

Continued...

How to find the last identity value inserted in the SQL Server

Hi,

When inserting a row in the database with an identity column as a primary key, most of the time we need to capture the new identity value generated. In SQL Server there cane as many as three approaches for the same.

            @@IDENTITY

            SCOPE_IDENTITY()

            IDENT_CURRENT(‘tablename’)

All of them can be used to find the last identity value inserted in the database, but they differ in the functionality depending on the scope or source of the insert as well as the connection that insert the row.

Continued...

EventHandler simplified with extension method

Hi,

One of the good uses of extension method that one of my friends told me when in discussion was to also reduce the code, by using extension method in the right place.

The first example we came into was firing of an event. When we need to fire an event we always need to make a check if the Event is null or not. Only in case when event is null (meaning there is at least one function pointer attached) we raise the event.

But this checking for null can be easily made generic with the help of an extension method. We can easily create an extension method on the class EventHandler. After that all we need to do is calling the new extension to raise the event and that will take care of checking for the null. Here is the code for the same

public static void RaiseEvent<TEventArguments>(

Continued...

What happen when we create an extension method with the name with which an instance method already exists

Hi,

One of the interesting things that I have not yet mentioned about the Extension method is there naming convention. In dot net framework 3.5 there is not restriction on the naming convention of the extension methods.

What this means is that we can have two extension methods with the same name. In fact we can have an extension method with the same name as an instance method of the class.

So an extension method like ToString() can be added to the object although the same method already exists in the same class. The method call will be selected in the following order.

Instance method.

Extension method with the same namespace

Extension method outside the current namespace

Vikram


Lambda expression – predicate and projection

Hi,

I have discussed about the lambda expression in my previous posts. In this post I will talk about predicate and projection. Predicate and projection are type of Lambda.

Some of the Lambda expression have particular name, which is based on their purpose. Predicate and projection are two type of Lambda expression, which have their name, based on the purpose.

Predicate – A Boolean expression that is intended to indicate membership of an element in a group is called predicate. Below is an example of the Lambda expression, which is predicate.

( Count ) => count > 1000

Here this lambda expression is returning a Boolean expression and is intended to indicate the membership existence. Hence it is a predicate.

Continued...
 
Copyright © 2006 - 2008 Vikram Lakhotia