Manish Pansiniya’s Blog

.NET, C#, Javascript, ASP.NET and lots more…:)

Archive for the ‘.NET 3.0’ Category

Server Tags <%…%>

without comments

<% %> An embedded code block is server code that executes during the page’s render phase. The code in the block can execute programming statements and call functions in the current page class. http://msdn2.microsoft.com/en-gb/library/ms178135(vs.80).aspx

<%= %> most useful for displaying single pieces of information. http://msdn2.microsoft.com/en-us/library/6dwsdcf5(VS.71).aspx

<%# %> Data Binding Expression Syntax. http://msdn2.microsoft.com/en-us/library/bda9bbfx.aspx

<%$ %> ASP.NET Expression. http://msdn2.microsoft.com/en-us/library/d5bd1tad.aspx

<%@ %> Directive Syntax. http://msdn2.microsoft.com/en-us/library/xz702w3e(VS.80).aspx

<%– –%> Server-Side Comments. http://msdn2.microsoft.com/en-US/library/4acf8afk.aspx

Written by Manish

November 10, 2009 at 11:57 pm

Posted in .NET, .NET 3.0

Tagged with , ,

Debugging Web Page (Performance, Errors, DOM etc.)

with one comment

If you are web developer, you should following tools for the debugging as well as performance improvement and other functionality. First of all install FireFox browser. I am not going into details of each tool as you are very smart to understand it :)

Here is quick list:-

FireBug

image

YSlow

image

Fiddler

image

If you know any other useful stuff for web debugging, you are most welcome to add that to the list.

Written by Manish

July 20, 2009 at 9:21 pm

Posted in .NET, .NET 3.0

Tagged with , , ,

ASP.NET Error: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.

without comments

 

I was working with the page and one silly mistake has taken my mind :P . Could not figure out at first sight but after debug, it would be found out.

I was doing Following:

try
{
    SaveShoppingInformation();
    RedirectToHome();
}
catch (Exception ex)
{
    throw new Exception("User Information: " + SessionHelper.UserInformation + ex.Message,ex);
}

Now the issue is, When you cover the exception on Response.Redirect, it gives the same error. Following is the solution.

try
{
    SaveShoppingInformation();
}
catch (Exception ex)
{
    throw new Exception("User Information: " + SessionHelper.UserInformation + ex.Message,ex);
}
RedirectToHome();

It resolves my issue :)

Written by Manish

July 14, 2009 at 9:49 am

Posted in .NET, .NET 3.0

Tagged with

Abstract Classes Vs. Interface – Why and When

without comments

As you know the difference between abstract class and interface, sometimes I wonder what to use in project.

Abstract Classes is similar to interface but might be with implementation.

Interface is without implementation, just interface or virtual methods.

As per my understanding, it is can-do or is-do relationship. Like, from .NET framework, there are many interface like IComparer, ISortable etc. So, it is something like, classes derived from the interface CAN-DO these things.

But if the abstract class is CompareBase and if you are deriving classes from this class named TestCompare, then you can say that TestCompare IS DOing CompareBase.

Actually, you can find awkward but if you think over it, you can get this concept easily. Also, when you are deriving from multiple inheritance, you can say like, this class CAN DO this and CAN DO that etc.

Hope You Getting This :D

Written by Manish

April 20, 2009 at 11:20 pm

Boxing & Unboxing in c# (.NET) – Why & What

without comments

This post is just yet another explanation about boxing and unboxing. Before that let us look at just in one line that what is value type and reference type.

Value Type contains actual data and it is stored always on stack. This cannot be null anytime.

Reference Type contains reference/pointer to actual data. Data is stored on heap. This can be null.

Now, as per all the website, boxing is to convert value type to reference type and unboxing is to convert reference type to value type.

But I was thinking, why to convert it from one type to another. The reason I found is, sometimes, you require value type must be passed as reference type e.g. System.Object as parameter. So if you define System.Int32, it allocates 4 bytes to the stack. And if it is passed as System.Object, it is boxed as referenced type and passed to the method. Due to that, System.Int32 behaves exactly same as object. However, in reality, it is just a 4 bytes.

So because of boxing, everything appears as Object (Reference type).

In unboxing, the reference type is converted back to the Value type. But if you look at all the unboxing code, you can find out that explicit cast is required to do the same. That is because CTS need to know whether you are converting the reference type to valid value type due to strict rules.

:) Quite Interesting!!!

Written by Manish

April 20, 2009 at 12:13 am

Refactoring Tip: Extract Method

without comments

Refactoring code should be must part of the coding. There are many benefits to refactor your code. Some benefit you can see directly and some benefit will be seen when you get major changes from the client :) . Sometimes client gives changes and it converted to Heart Attack automatically. LOL. But if you have followed good programming practices and has coded well, you have always a gr8 day (in your project. I could not say anything about evil in your personal life :) ).

If I start writing book then it may take 2 years to share for the refactoring the code as it may contains patterns, practices, methods, standards etc to follow…

One of it is Extract Method. You need to extract the group of code into the understandable method. It will add bit overhead but that is negligible considering understanding and maintainability. Following is one example of Refactoring from the book. It is very basic example but you can understand the concept from the same

image

Written by Manish

April 18, 2009 at 12:54 am

ThreadManager (C# Threading class) is now on CodePlex

without comments

 

I have uploaded ThreadManager class as new project on CodePlex. So it can be downloaded and used from there. It is really simple class to use with threadpool implementation. Already tested!!! :) . Following is the URL

http://threadmanager.codeplex.com/

There are other projects for Threading on CodePlex website. You can search using ‘Threading’ and get the same.

EnJoY!!! ::):)

Written by Manish

April 7, 2009 at 6:30 pm

Download books free – eBooks, Audio Books, .NET, ASP.NET, C#, Great Site

with 2 comments

Just went by one site which has really a good collection of books for free.

http://www.knowfree.net

Just ViSiT…and Download Good books for you!!! & Yes, dont forget to say thanks to me :P

Written by Manish

April 1, 2009 at 7:09 pm

SQL Query Formatter

with 4 comments

Due to requirement of one of my project, i have developed SQL Query formatter in a quick way. It is long way back to 2006. Now, i am thinking that why not to share with the people. So i am sharing it right now.  There are still some problem in the formatter. I will soon post this project to CodePlex to enhance it :) . So please try it and let me know how can we make it big :) .

QueryFormatter.zip

QueryFormatter Let me know your feedback!!! :)

Written by Manish

March 27, 2009 at 2:52 pm

Easiest Method to Find Point on Circle

without comments

Following is the code to detect whether point is in circle or not :

public static bool IsPointInCircle(UnitPoint center, float radius, UnitPoint testPoint, float halflinewidth)
        {
            float dist = Distance(center, testPoint);
            if ((dist >= radius – halflinewidth) && (dist <= radius + halflinewidth))
                return true;
            return false;
        }

 

Parameter contains Center Point, radius and test point. halflinewidth is same as threshold value. So that it will check the point for Circle with some width provided in halflinewidth.

It finds distance from center and if that distance somehow in between radius and halflinewidth radius. :) quite easy. Let me know if you need more detail into that.

Written by Manish

March 27, 2009 at 1:00 pm

Posted in .NET, .NET 3.0, Algorithm, OpenGL