September 2006 - Posts

ASP.NET 1.1 to ASP.NET 2.0 Migration #4

This problem does not applies to every situation. I faced this issue earlier today as I was migrating some codes from .NET 1.0 (back in Visual Studio .NET 2002 days) into ASP.NET 2.0.

The problem is most developers who moved into the .NET 1.0 platform came from VB6 background. So most of them will just create public variable declarations instead of having properties. Probably property was something new to everyone back then and not everyone followed best practices.

Example,

public class WebForm

{

  public SomeClass a;

  protected System.Web.UI.WebControls.TextBox txtUserName; 

}

But when you tried to migrate that code above into ASP.NET 2.0, you will need to add partial keyword into that class. Then you need to comment out that 2 declarations as it is already been generated behind the scene.

Just say somewhere below this class, it will perform some calculation that will need to use a.

When you compile it, you will get this error "... inaccessible due to its protection level"

So what is the problem? It is definitely related to your access modifiers. But where. I checked almost everywhere and it looked okay.

Why this problem existed?

(Correct me if I am wrong)

When you place a partial class, it will generates the declarations behind the scene for you. Like this:

  protected SomeClass a;

  protected System.Web.UI.WebControls.TextBox txtUserName; 

If you notice, a is not longer under public but protected.

In order to get it working, just create a public property like this:

public SomeClass A

{

  get { return a; }

}

Then use A instead of a.

Hope it helps. But I am not sure this applies to every situation.

Posted by chuawenching with no comments

ASP.NET 1.1 to ASP.NET 2.0 Migration #3

This is quite important when you place references of class libraries in your web application. There are times when you will change the path of these class libraries. You not going to right click on the project and add references again & again.

Example, if your current project name is ProjectA and you need to rename it as ProjectB. This happens as sometimes customers demand it, but you already named your projects accordingly.

What you can do is simple?

In your bin directory in your web application http://localhost/MIND, say:

bin

-> A.dll

-> A.pdb

-> A.dll.refresh

-> B.dll

Right click on A.dll.refresh file and open with notepad. You will see as below:

..\..\ProjectA\ClassLib\bin\Debug\A.dll

change it to:

..\..\ProjectB\ClassLib\bin\Debug\A.dll

Simple right. This is very important. If you don't do this, you will get a warning in your Visual Studio 2005 stating that there is no auto refresh to the particular dll.

I am not sure is there any better and simpler way. If there is, let me know :D

Updated: I just noticed that sometimes the DLLS were not updated even you had .refresh files.

Posted by chuawenching with no comments

ASP.NET 1.1 to ASP.NET 2.0 Migration #2

I believe that MS_POSITIONING keyword is deprecated in ASP.NET 2.0.

ASP.NET 1.1

<body MS_POSITIONING="FlowLayout">

ASP.NET 2.0

By default, ASP.NET 2.0 is based on Flow Layout. So just remove the MS_POSITIONING keyword.

<body>

But how about GridLayout?

That is a very good question. Since all the ASP.NET 2.0 by default are based on FlowLayout, how can we change this?

ASP.NET 1.1

<body MS_POSITIONING="GridLayout">

ASP.NET 2.0

You still have to remove the keyword MS_POSITIONING like this:

<body>

But in order for you to use grid layout for absolute positioning of controls, do this:

In your VS 2005 IDE, click on Tools -> Options -> HTML Designer -> CSS Positioning

Then checks the "Change positioning to the following for controls added using the Toolbox, paste or drag and drop", then selects "Absolute Positioned"

OR you can do this:

Say you only want certain control to be absolute and others still based on flow layout. Select a control on the designer and then go to Layout -> Position

Change from Not Set to Absolute

Hope you find it useful :D

Posted by chuawenching with no comments

ASP.NET 1.1 to ASP.NET 2.0 Migration #1

Guess this is the easiest migration tip that everyone already know. But I still like to share to those people who do not know.

ASP.NET 1.1

In your ASP.NET source file, you will be using Codebehind like this:

<%@ Control Language="c#" Codebehind="SomeFile.ascx.cs" ... %>

Just imagine you have 2 text boxes controls in your designer form.

In your code behind which is your c# code, you will see this:

public class SomeFile : System.Web.UI.UserControl

{

  protected System.Web.UI.WebControls.TextBox txtUserName;

  protected System.Web.UI.WebControls.TextBox txtPassword;

}

The question is how do you migrate this over to ASP.NET 2.0

ASP.NET 2.0

In the ASP.NET source files, changes Codebehind to CodeFile

<%@ Control Language="c#" CodeFile="SomeFile.ascx.cs" ... %>

Then in your code behind, add partial keyword before your class. Later comments the 2 TextBox declarations:

public partial class SomeFile : System.Web.UI.UserControl

{

  //protected System.Web.UI.WebControls.TextBox txtUserName;

  //protected System.Web.UI.WebControls.TextBox txtPassword;

}

That's simple right :D Hope you find it useful.

Posted by chuawenching with no comments

More talks in year 2006

Below is the list of talks that I will love to speak at:

a) UNIMAS, Sarawak (not confirmed yet, haven't receive the date and venue)

b) SgDotNet Academics Developer Conference (I am not sure whether I am a confirmed speaker yet)

c) November and December MIND's session

I think I won't speak more than that as I will be busy with project development at work.

Posted by chuawenching with 2 comment(s)

My 1st phone Sony Ericsson W810i + Maxis Postpaid

Yes, I finally bought my 1st phone Sony Ericsson W810i for RM1,100.

http://www.sonyericsson.com/spg.jsp?cc=gb&lc=en&ver=4000&template=pp1_loader&php=PHP1_10376&zone=pp&lm=pp1&pid=10376

I love this phone so much, even it is not the best phone out there.

It comes with a walkman (which I hardly use) and a camera phone. Nice with camera phone, I can take a lot of pictures during events and those pretty girls. Haha. Sounds like a pervert. Kidding :D

Suprisingly I never bought any phone my whole life.

1st phone was Motorola - Dad gave me the money and brother chose for me

2nd phone was Nokia 8310 - Brother gave me but dropped in the toilet bowl, ended up with my Mum :P

3rd phone - I switched my Nokia 8310 with my Mum's new phone which only costed RM50

Finally I had my Maxis post paid ready. I will not give any lame excuses any more saying that my handphone has no credits.

Posted by chuawenching with 4 comment(s)

Hope to speak more

I will be trying very hard this month onwards to speak more in events. Probably smaller ones to students and professional audience. I will treat MIND as a starting ground to speak. Thanks to Fun Jin and Sin Min advices.

I believe that I had been speaking like a kid with my Manglish slang "Lah", "Loh". This is very bad. I need to be more professional when speaking to any audience.

Most of the time I don't sound convincing. I have to work out on this one too.

Hope I can be a good speaker like William Tay. So many people in Malaysia respect him. Including myself.

Posted by chuawenching with no comments

Speaking in APIIT .NET Day 2006

I am very grateful to be invited by the Microsoft Student Ambassadors in Malaysia and Microsoft to speak in APIIT .NET Day 2006.

http://webspace.apiit.edu.my/features/2006/DotNetSig/poster.jpg

I will be speaking on DirectX 10 and XNA Technologies this time. There will be demos :D I promised this time.

I am still trying to get my Visual C# Express installed in my Windows Vista RC 1. Probably today I will consult the Infra people in my company to setup the wireless connection in my Windows Vista, so I can download that software.

If I fail to do so, probably I will skip DirectX10. I might need Windows Vista to show off some demos.

APIIT .NET Day brings a lot of memory to me. I was one of the coordinators back then to organize this event.

Will post up pictures after this session :D

Posted by chuawenching with 1 comment(s)

I am back to blogging again

Hi there,

  I am back to blogging in SgDotNet site. I was thinking a lot whether I should continue blogging. Maybe in MIND or INETA Academics site. But I had already been blogging in SgDotNet for a while last time.

  Why reinvent the wheel? So I had decided to stay on with SgDotNet and hopefully to blog :D

  Hope the people here still welcome me.

Thanks.

Posted by chuawenching with no comments