Visual studio 2008 cute dialog on the Ctrl + Tab

Hi,

One of the cool new stuff in Visual Studio 2008 is the way it works with the Ctrl + Tab. In Visual Studio (VS) 2005 this feature was brought up and has been nicely enhanced in Visual Studio (VS) 2008.

In VS 2005 when we press Ctrl + Tab the studio would just not cycle through the opened tabs but open a dialogue to show those tabs. This way we were easily able to see the next tab which would be opened.

This feature has been well built on in VS 2008. In Vs 2008 ctrl + Tab not openly open the dialog but also show the image preview of the window. Here is an example of the window that shows up.

The feature might be small and simple but is pretty useful. It least I have liked this beautiful work from VS 2008 team. Way to go… Here is an image of the dialog.

Ctrl + Tab effect in Visual studio 2008

Continued...

In IIS 7.0 HttpContext.Current property in Application_Start cannot be accessed

Hi,

One of the major changes in IIS 7.0 is that the HTTP context is not available in the application_start event. If you try to work with the http context (with the help of Httpcontext.current) in the application_start event in global.asax then you will receive an ASP.NET 500 – Server Error: Request is not available in this context.

In IIS 7.0 the Application Initialization has been decoupled from the request that has triggered the application start and hence the request is not available in the vent. In the classic mode , it was possible for us to indirectly access the request as the Asp.net initialization directly coupled with the request for which the application was started.

Continued...

Dot net framework 3.5 breaks the LINQ to SQL code. Here are the changes

Hi,

With the release of dot net framework 3.5, its time to get work with LINQ in live projects. For those who have used LINQ in the beta 2 version can use the previous code in the latest version.

But there are small breaking changes that have been made in the framework, which needs to be incorporated in the code of the beta version. Here are some of the changes that need to be made from the previous version

In the LINQ to SQL the Add method has been changed to InsertOnSubmit. Similarly AddAll method name has been changed to InsertAllOnSubmit. The remove and RemoveAll method have also been changed to DeleteOnSubmit and DeleteAllOnSubmit

Another breaking change is that the

<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

[Note: The version has been changed

Continued...

How to read XML data sent in a post request

Hi,

A few days ago I posted about how we can send XML data as a post request to any URL. You can read the stuff here. After that many people have asked me on how we can read the data when data is sent as a Post Request.

Reading data when it is sent as a post request value is very simple. We use the Request.InputStream to read the incoming stream request. Here is a glimpse of code to work with the same.

byte[] b = new byte[Request.ContentLength];

Request.InputStream.Read(b, 0, Request.ContentLength);

Here we first get the length of the request and then read the same in an array of byte.

We can convert the bytes into a string by using correct encoding. (Note: I am using the UTF8 encoding for example).

Continued...

Installing the release version of Visual studio 2008 after uninstalling the beta 2 version

Hi,

Today I installed Visual studio 2008 release version. But truly speaking the installation was not as smooth as I thought it could have been. So I decided to talk about one specific problem that I faced and the solution for that.

Before I say anything about the problem, one important thing. If you have installed the beta 2 version of the software (as I did) then you first need to uninstall the same. I am using Vista, so I will talk about Vista Operating system only.

In most of the places you will find message like go to control panel -> add remove program and then remove the component of visual Studio 2008 beta 2. But if you are using Vista and you go to control panel -> add remove program you will not find any option to remove the program from the system over there.

Continued...

Microsoft set to release IE8 in first half of 2008,passes Acid2 test

Hi,

Two days ago Microsoft announced Wednesday it has passed an early milestone for the next version of its iconic Internet Explorer. An early version of the pre-beta code for IE 8.0 has successfully passed the so-called Acid2 browser compatibility tests

IE8, the next upgrade to Microsoft's browser, passes the Web Standards Project's Acid2 test, according to Dean Hachamovitch, the IE group's general manager.

Hachamovitch also said - We're listening to the feedback about IE, and at the same time, we are committed to responsible disclosure and setting expectations properly.

IE8 is expected to come out in the first half of the next year. Way to go IE team.

Vikram


How to prevent client cache and getting a server request even when back button is clicked

Hi,

Many a times we do not want browser to show data from cache. For example when user hits the back button of the browser, the browser shows the last page from the cache and does not make a post back to the server. (This is why when some one clicks on the back button of the browser the system looks so fast).

But many a times we do not want the browser to show data from the cache. There are requirements where the data is very dynamic and if browser shows the data from the cache then it can give wrong indication to the user.

Controlling the back button of the browser is not such a good idea because we are trying to stop the user at the client end.  But what we can do is ask the browser to not to cache the page in the client end and always make a call to the server before showing the page.

This can be easily done by expiring the response. Here is the code for the same.

Continued...

How to create a POST request and send XML data

Hi,

Many a times when we are working with the third party services we have to pass the data to the third party over the web. Most of the times we pass the data in the querystring. The data is passed in a get request along with the querystring. The third party takes the value from the querystring and process the data.

But many a times the data need to be passed in the Post method. Many a third party component takes the data in XML format in the POST request. In these cases we have to pass the data as XML string in the post request. Here is an example on how to pass XML in the post request.

string xml = “SomeXML Data”;

string url = @”http://www.vikramlakhotia.com/HomePage.aspx”;

WebRequest request = WebRequest.Create(url);

Continued...

Using tag mapping to change the mapping of user control through out the application

Hi,

Lets say you are working in a fairly large asp.net application. You have about 200 web pages. Now because of situation (or clients request) you want to change all the textbox or button control to some server control or user control.

This can be very very tedious JOB if you are using Asp.net 1.X. But if you are using Asp.net 2.0 or Asp.net 3.0, wait, there is a very easy way to get this done.

Tag mapping seems to be made for these kinds of situations. In asp.net 2.0 we can map tags in web.config. With the help of tag mapping we can remap the tag types to other tag types at compile time.

The remapping will make all the original tag to use the new mapping for all the pages and user control in the asp.net application coming in scope of the configuration file.

Continued...

Executing JavaScript function after update panel has updated

Hi,

Last week I was working on a project and integrating AJAX to some existing code base. I had two small requirements. I wanted to run different JavaScript function once the server side execution is finished.

I had one function which was needed to fire after and or every update panel update, and some other JavaScript function to fire on specific update of update panel.

To execute a JavaScript function after any and every update panel update we can use the following code.

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(foo);

This will make the JavaScript function foo() to fire after every update panel update.

Continued...

Reducing the size of HTML by removing the ID of control when not required

Hi,

Many a time we have many server controls with long Id which are never required once there value has been set. We normally disable their viewstate to reduce the size of both viewstate and the page. Especially if these controls are inside nested repeaters (or grid view or likes) the view state size can be huge.

Making the viewstate false reduces the size of the viewstate but when these controls are rendered they render with a long ID. If we are using a master page than the ID of such a label (or other controls) would be something like Ctl100_ + Contentplaceholderid + Repeater Name + ct102 + the label of control. If the repeater is nested than the name of ID can be very very large.

Continued...

What are the limitation of different trust level in a application

Hi,

Most of us have worked with web application and one thing which is very commonly heard is of trust level at which the application is running. I have read many articles which talks (in some way or the other about trust level of the application). But I also feel that most of the developers do not know the limitations or capabilities of different levels.

Here is a list of major restriction and capabilities for an application at different trust levels.

Full trust –

No restriction is imposed on the application by the code aces security.

High trust  -

Continued...
 
Copyright © 2006 - 2008 Vikram Lakhotia