Thursday, July 03, 2008

MasterPage.master.cs does not exist error

I got the very weird error with ASP.NET 2.0 deployment. It has been running well in my development machine. Then, I published my test WebApplication project from visual studio to make release the compiled dll so that the application can be run on server without deploying .cs source code files. But after published it, the system gave the error “MasterPage.master.cs does not exist”.

It was very weird and it tempted to me considering whether it’s because “.cs” files are also required to deploy. But if that’s was the case, what’s the point of publishing?

After a while, then I finally realised that MasterPage I created doesn’t have namespace.

After I added namespace in masterpage.master.cs file and published it again. Then, It was fine.

In ASP.NET 2.0, it seems like

- WebApplication project requires to have namespace for every class in the project if you deploy the system by publishing (.dll and aspx only).

- WebSite project, it seems doesn’t require to have namespace even though if you deploy it by publishing.

Server Error in '/WebAppTest' Application.


Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The file '/WebAppTest/MasterPage.master.cs' does not exist.

Source Error:

Line 1: <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

Line 2:


Source File: /LEGATOTest3/WebAppTest.master Line: 1


Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434

Wednesday, June 11, 2008

ASP.NET Menu & DataSet

I had a requirement to build dynamic configurable menu and data will be populated from database rather than web.sitemap. And also the menu must support unlimited hierarchical levels. And also this piece of code must be reusable.

My idea was to bind the menu directly with dataset but unfortunately, dataset is not inherited and implemented IHierarchicalDataSource and it throws the exception. So, I tend to do traditional way of by adding menuItem in the loop. I know this is not a good idea and there must be someone who already implmented the neater way of binding directly by tweaking the dataset as the ASP.NET Menu has been released since 2 or 3 years ago.

Just a couple minutes spending on google and found this which is neater code and better design.

http://aspalliance.com/822

By using XMLDataSource and XSLT, this support unlimited hierarchical levels and only a few line of codes and clean.

Just have a look that above link if you are looking for building dynamic menu, it's worth to look it at.

Cheers

kick it on DotNet

Saturday, December 08, 2007

Google Chart


Google released Chart API which lets your web page to generate the Chart dynamically. Several types of image can be generated: line, bar, and pie charts for example. For each image type you can specify attributes such as size, colors, and labels.

How it works
- Request the url with chart parameters in query string, Google will response the “png” image chart.
E.g. http://chart.apis.google.com/chart?cht=p3&chd=s:hW&chs=250x100&chl=Hello-YWorld-X
- Use with <img> tag
E.g. <img src="http://chart.apis.google.com/chart?cht=p3&chd=s:hW&chs=250x100&chl=Hello-Y|World-X" /></IMG<>


Usage Policy
The Use of the Google Chart API is free but it is subject to a query limit of 50,000 queries per user per day. If you go over this 24-hour limit, the Chart API may stop working for you temporarily. If you continue to exceed this limit, your access to the Chart API may be blocked.

URL format
Google Chart API URLs must be in the following format:
http://chart.apis.google.com/chart?
chs=200x125
&chd=s:helloWorld
&cht=lc
&chxt=x,y
&chxl=0:|Mar|Apr|May|June|July|1:||50+Kb


Where:
· http://chart.apis.google.com/chart? is the Chart API's location.
· & separates parameters.
· chs=200x125 is the chart's size in pixels.
· chd=s:helloWorld is the chart's data.
· cht=lc is the chart's type.
· chxt=x,y indicates both x-axis and y-axis labels are required.
· chxl=0:|Mar|Apr|May|June|July|1:||50+Kb are the x-axis and y-axis labels.

Sample chart

Reference:
http://code.google.com/apis/chart/
Other Resources:
.Net server controls for google chart - http://pietschsoft.com/Blog/Post.aspx?PostID=1429

Have a nice day!

Wednesday, December 05, 2007

What's New in .Net 3.5

I have been checking about recently released .net 3.5 in these few days and there are many really pretty exciting features out there and also practically useful, applicable, lesser lines of code required and more productive in day to day works. I would say that Microsoft really made another major mile stone with .net framework achievement.

here are a few features I learned from the blogs and communities.

  1. Implicitly Type Local variables
  2. Anonymous Types
  3. Automatic Properties, Object Initializers, and Collection Initializers
  4. Extension Methods
  5. Lambda Expressions ( => )
  6. Language Integrated Query (LINQ)
  7. LINQ to SQL

1.Implicitly Type Local variables

Local variables can be given an inferred "type" of var instead of an explicit type. The var keyword instructs the compiler to infer the type of the variable from the expression on the right side of the initialization statement.

Compiler works for you to convert to the right type during compilation and so, from IL perspective, it sees as the type converted by compiler.

// i is compiled as an int

var i = 5;

// s is compiled as a string

var s = "Hello";

// a is compiled as int[]

var a = new[] { 0, 1, 2 };

// expr is compiled as IEnumerable<Customer>

var expr =

from c in customers

where c.City == "London"

select c;

// anon is compiled as an anonymous type

var anon = new { Name = "Terry", Age = 34 };

// list is compiled as List<int>

var list = new List<int>();

2.Anonymous Types

Anonymous types are a convenient language feature of C# and VB that enable developers to concisely define inline CLR types within code, without having to explicitly define a formal class declaration of the type.

Anonymous types are particularly useful when querying and transforming/projecting/shaping data with LINQ.

var person = new { FirstName = "Kyaw", LastName="Oo", BirthPlace="Yangon" };

Response.Write(person.FirstName);

For more detail, read here.

3.Automatic Properties, Object Initializers, and Collection Initializers

Isn’t it cool if you can write the class like below without requiring the private member and the compiler will automatically create the private members and map these to properties?

No need to declare private member and compiler will do it for you. But later if you want to modify the property for adding extra validation codes, you still can do without breaking to the client codes.

Automatic Properties

public class Person {

// Auto-implemented properties

public string FirstName { get; set; }
public string LastName { get; private set; } //Read Only
public int Age { get; set; }
}

Object Initializers

New alternative way of initializing the object. Cool, huh?

Person person = new Person { FirstName="Scott", LastName="Guthrie", Age=32 };

Collection Initializers

For more detail, read here.

4.Extension Methods

In old days, you will write your validation codes like below.

string email = Request.QueryString["email"];
if
( EmailValidator.IsValid(email) ) {
}

Have you ever thought about that you could write something like in C#, VB.NET? Now, it’s possible in .Net 3.5 .

string email = Request.QueryString["email"];
if(email.IsValidEmailAddress()) {

}

For more detail, read here.

5.Lambda Expression ( “=>” )

The => token is called the lambda operator. It is used in lambda expressions to separate the input variables on the left side from the lambda body on the right side. Lambda expressions are inline expressions similar to anonymous methods but more flexible; they are used extensively in LINQ queries that are expressed in method syntax.

string[] words = { "cherry", "apple", "blueberry" };

int shortestWord = words.Min(w => w.Length);

The => operator is read as "goes to." In the previous example, the expression is read as “Min w goes to w dot Length”.

The => operator has the same precedence as the assignment operator (=) and is right-associative.

public class Person

{

public string FirstName { get; set; }

public string LastName { get; set; }

public int Age { get; set; }

}

6.Language Integrated Query (LINQ)

This is the most productive and very useful feature in .Net 3.5 and it gives the developer to save the tremendous development time on data access layer codes.

Language Integrated Query (LINQ, pronounced "link") is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages using a syntax reminiscent of SQL.

http://en.wikipedia.org/wiki/Language_Integrated_Query

7.LINQ to SQL

This is how LINQ supported for SQL database. The following link will give you the comprehensive detail of LINQ – SQL insight.

http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx

For further reading:

http://weblogs.asp.net/scottgu/archive/2007/11/19/visual-studio-2008-and-net-3-5-released.aspx

http://resharper.blogspot.com/2007/10/c-30-automatic-properties-incomplete.html

Have a nice day!


kick it on DotNetKicks.com

Thursday, November 29, 2007

Daily references for .net developer

Developer reference
All about microsoft SDK is here
http://msdn.microsoft.com/library
If you are looking for something which guides you best practices which will bring you next level of your code quality, here you go.
http://www.guidancelibrary.com/

Javascript/HTML/XML Guide
http://developer.mozilla.org/en/docs/Main_Page

Best developer Tools I like

1. Code generation tools
www.mygenerationsoftware.com/

2. HTML/HTTP Hacks (Web Development Helper)
http://www.nikhilk.net/Project.WebDevHelper.aspx
http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038&displaylang=en
https://addons.mozilla.org/en-US/firefox/addon/60 (For Firefox)

3. Javascript compression tool
http://shrinksafe.dojotoolkit.org/

4. File/Folder comparison (source diff)
http://www.sourcegear.com/diffmerge/downloads.html
I will update this post when I have time later.

Tuesday, July 19, 2005

Cool Microsoft Visual Source Safe Web Interface

Are you a user of Microsoft VSS 6? If so, you might sometimes feel that VSS is able to work only at the office LAN environment and

it’s really a big limitation for the ones who want to work at home smartly or who are away from office.

For this potential barrier, ComponentWorkshop produced the VSS Web Interface and it can be able to work through internet.

That is really nice and cool one.

Just check it here.

http://www.componentworkshop.com/Default.aspx?cid=440

Monday, July 18, 2005

MSF For CMMI process improvement...

Microsoft released the process how the coming VS.Net 2005 studio Team system can be applied in the CMMI level organizations...Although the organization is not CMMI one, it can also practice the best software development practices by using MSF model and VS.Net 2005 team system. This process work flows and explanation are explained in the following download.
http://www.microsoft.com/downloads/details.aspx?FamilyID=10B578F1-B7A4-459F-A783-04BC82CB2359&displaylang=en
Just download it and have fun. :)

Thursday, June 30, 2005

Hey...This is a testing

This is a testing.

Monday, June 20, 2005

Microsoft Tech-Ed 2005 Webcasts

Microsoft has just published downloads for the web casts of Microsoft Tech·Ed 2005 in Orlando, Florida.

Just check it here.

http://www.microsoft.com/events/series/teched2005.mspx

Friday, June 17, 2005