Thursday, November 20, 2008
How to reset AutoNumber in Microsoft Access table?
Tuesday, November 18, 2008
To lock your computer
Tuesday, November 11, 2008
StrConv function - to capitalize the first character in the sentence
Constants | Value | Description |
vbUpperCase | 1 | Convert to uppercase |
vbLowerCase | 2 | Convert to lowercase |
vbProperCase | 3 | Convert the first letter of every word in string to uppercase |
Monday, November 10, 2008
New line character in Excel cell
Friday, July 25, 2008
Understanding the differences between Cache, Session and ViewState
My colleague sent this article to us recently. After I've read it, I found it quite useful and easy to understand, just wanna share it out.
In the article, it introduces these 3 types of storage methods: Cache, Session, ViewState.
To be honest, I only used session before. :p
It's time for me to learn how to use the storage methods probably, to make the web application better.
These are the notes I've taken:
----------------------------------------
Cache
- memory.
- allow you to store difficult and complex constructed data which will can be reused.
- is available to be accessed from global/application level where one reference to memory is updated. Each request will use the same cache for different users.
Session
- a period of time that is shared between the web application and the user.
- Each user that is using the web application has their own session.
- The Session variables will be cleared by the application which can clear it, as well as through the timeout property in the web config file.
- Session variables will use different session variables for each different user.
ViewState
- hidden data that is kept by ASP.NET pages.
- track the changes to a web site during post backs.
- All server controls contain a view state.
[EnableViewState property - enable/disable if the control properties will be held in hidden fields.]
- Having a large ViewState will cause a page to download slowly from the users side.
- When a user clicks on a button and a post back occurs, all the view state information has to be posted back to the server which causes a slower request.
- ViewState should be limited to what is needed.
- Data can also be written into the ViewState.
- The ViewState only persists for the life cycle of the page.
- If the page redirects to another page, or even to itself, the ViewState will be reset.
- ViewState should be used to hold small amonts of data, which will be only used on the current page.
Wednesday, April 9, 2008
Show message box in ASP.NET
I've written a simple function which uses JavaScript.
private void ShowMessageBox(string Message)
{
Label lblMessageBox = new Label();
lblMessageBox.Text =
"<script language='javascript'>" + Environment.NewLine +
"window.alert('" + Message + "')</script>";
Page.Controls.Add(lblMessageBox);
}
To call out the message box, just write this:
ShowMessageBox("Hello world!");
The problem with this is that I can't customize the message box. I can only pass in the message as parameter, but not changing the title, the button text or image.
Wednesday, April 2, 2008
Add javascript dropdownlist in your blog
I was looking for a way to add a dropdownlist in my blog, finally I've found this. It's simple and it's what I want.
I do not know why the above dropdownlist is not working, but when you copy these codes to your blog, it should be able to work.
Just copy the following codes, and add to your blog. In Blogger, Add these codes in HTML/Javascript element, then it works fine.
<!--BEGIN dropdownlist--><script language="JavaScript">
function selectOption(selObj){
window.open(selObj.options[selObj.selectedIndex].value);}</script>
<select style="background: #c6e2ff; color: #000000" onchange="selectOption(this)">
<option value="">- Please select -</option>
<option value="http://www.google.com">Google</option>
<option value="http://www.yahoo.com">Yahoo</option>
<option value="http://www.msn.com">MSN</option></select>
<!--END dropdownlist-->
Monday, March 24, 2008
Set security access to folder
I'm currently doing a small function, where I need to create folder dynamically, if the folder does not exist.
Creating folder is easy, but I also need to set the security access. Finally, I've found the way of doing this.
I have created a simple class to perform this Directory-related tasks, named "Folder".
Firstly, we need to include System.IO (for Directory class) & System.Security.AccessControl (for FileSystemRights & AccessControlType enums).
public static bool Exists(string folderPath)
{
return Directory.Exists(folderPath);
}
public static void Create(string folderPath)
{
Directory.CreateDirectory(folderPath);
}
public static void Delete(string folderPath)
{
Directory.Delete(folderPath, true);
}
public static void AddSecurity(string folderPath,
string userAccount,
FileSystemRights fileSystemRights,
AccessControlType controlType)
{
DirectoryInfo folderInfo = new DirectoryInfo(folderPath);
DirectorySecurity folderSecurity = folderInfo.GetAccessControl();
folderSecurity.AddAccessRule(
new FileSystemAccessRule(userAccount, fileSystemRights, controlType));
folderInfo.SetAccessControl(folderSecurity);
}
public static void RemoveSecurity(string folderPath,
string userAccount,
FileSystemRights fileSystemRights,
AccessControlType controlType)
{
DirectoryInfo folderInfo = new DirectoryInfo(folderPath);
DirectorySecurity folderSecurity = folderInfo.GetAccessControl();
folderSecurity.RemoveAccessRule(
new FileSystemAccessRule(userAccount, fileSystemRights, controlType));
folderInfo.SetAccessControl(folderSecurity);
}
public static string[] GetListOfFileSystemRights()
{
return Enum.GetNames(typeof(FileSystemRights));
}
public static string[] GetListOfAccessControlTypes()
{
return Enum.GetNames(typeof(AccessControlType));
}
Function: If the folder does not exist, create it and set security access.
if (Folder.Exists(folderPath) == false)
{
Folder.Create(folderPath);
Folder.AddSecurity(folderPath,"MY\\CHONGLK", FileSystemRights.Modify,AccessControlType.Allow);
}
Folder.RemoveSecurity(folderPath,"MY\\CHONGLK", FileSystemRights.Modify,AccessControlType.Allow);
The last two functions is to allow users to bind the list of enum values to the UI control.
//List all FileSystemRights values in dropdownlist
systemRightsDropDownList.DataSource = Folder.GetListOfFileSystemRights();
systemRightsDropDownList.DataBind();
//List all AccessControlTypes values in dropdownlist
controlTypeDropDownList.DataSource = Folder.GetListOfAccessControlTypes();
controlTypeDropDownList.DataBind();
It's quite simple, but I didn't know these methods before this. At least, I learnt something new.
Friday, March 21, 2008
List out all enum values
I just found out the way to list out all the enum values. It's indeed very simple!
For example, I want to list out all the enum values of FileAccess.
string[] enumList = Enum.GetNames(typeof(FileAccess));
DropDownList1.DataSource = enumList;
DropDownList1.DataBind();
FileAccess fAccess = (FileAccess)Enum.Parse(typeof(FileAccess), DropDownList1.SelectedValue);
MCPD: Learning Plan for Exam 70-536
You may also sign in to Micrsoft Learning to look for any learning resources, including the learning plan. You also also track your learning here.
In this learning plan, there are recommended learning resources, where you can follow them step by step until you reach the stage of registering for the exam.
I plan to follow this learning plan to start my learning process for Exam 70-536, then I'll see what extra resources I need when time goes by.
MCPD: Preparation Guide for Exam 70-536
This will be my first paper:
Exam 70-536 [Microsoft .NET Framework 2.0 - Application Development Foundation]
From the link above, you'll find these information:
- Exam news
- Exam topics covered
- Audience profile
- Credit toward certification
- Code languages
- Prepartion tools and resources
- Skills measured
I guess the most important is the skills measured section. You'll be told in detailed what knowledge are required in order to take the exam. You can use the long list to measure your knowledge.
I just jot down the keywords for exam topics covered in this paper:
1) system types & collections
2) service processes, threading, application domains
3) embedding configuration, diagnostic, management, and installation features
4) serialization & I/O
5) security
6) interoperability, reflection, mailing funcitonality
7) globalization, drawing and text manipulation
MCPD: Exam Question Types
I've found this site when I was looking for the information regarding MCPD.
There are several types of exam questions. It may be good if we get ourselves familiar with these types:
1. Hot area questions
This kind of question asks you to indicate the correct answer by selecting one or more elements within a graphic.
2. Active screen questions
This kind of question asks you to configure a dialog box by changing one or more elements.
3. Drag-and-drop quetsions
This kind of question asks you to drag source objects to appropriate targets within a work area.
4. Build list and reorder questions
This kind of question asks you to indicate the correct answer by building an answer list.
In a build list and reorder question, you need to build a list by dragging the appropriate source objects to the answer list and then placing them in the correct order based on criteria defined in the question.
5. Create a tree questions
This kind of question asks you to create a tree structure.
You indicate the correct answer by dragging source nodes to the correct locations in the answer tree.
Nodes consist of text and a small icon.
6. Testlet exam format
7. Windows 2000 simulation questions
This kind of question asks you to indicate the correct answer by performing specific tasks such as configuring and installing network adapters or drivers, configuring and controlling access to files, and managing hardware devices. (This seems to be more applicable for System engineering exams)
You may download the MCP Exam Demos too, then you'll understand better what the aboved question types mean. It's quite fun to run through the exam demo. ^_^
There is an "Instructions" button to tell you what type of question it is, and how you should respond. A "Calculator" button is provided too.
Wednesday, March 19, 2008
MCPD - Start the Journey
I have been thinking of taking this certification - MCPD (Microsoft Certified Professional Developer) for quite long. Well, actually I have been thinking since MCSD (Microsoft Certified Solutions Developer), then it changed to MCAD (Microsoft Certified Application Developer). Finally, there came a new generation again.
Finally, I've made a move - we've bought several books yesterday.
Perhaps this time, I'm really going to pursue this cert, because the company is sponsoring. haha~~
My boss has been asking us to look for external courses, and I think pursuing MCPD is a good idea. We've calculated the price of the books we are going to purchase, altogether 7 books, for 3 papers, cost us RM1600. It'll be a burden for me to spend this amount of money just on the books only. As the courses are too expensive, say RM2400 for 3 day course, that is RM800 for a day, RM100 for an hour. We've decided to study by ourselves, and we'll also see if there are any useful or interesting courses, then we can subscribe for them too. Perhaps we'll go for those topic-oriented courses, instead of going for the certication ones.
I wish I can spend one hour per day to study on this. Perhaps reading the books, doing some research online, taking some sample tests. See how it goes.
The papers I'm required to take are as follow:
1) Exam 70-536: Microsoft .NET Framework 2.0 - Application Development Foundation
2) Exam 70-528: Microsoft .NET Framework 2.0 - Web-Based Client Development
3) Exam 70-547: Designing and Developing Web Applications by using Microsoft .NET Framework
My first paper will be Application Development Foundation. I need to go and check out any resources for this MCPD, and hope to know anyone who's also taking or already taken this cert. ^_^
More to find out soon...... I gotta keep myself motivated. haha~~
Reference:
* MCPD Official website
Monday, February 18, 2008
Set GridView Header Font Style in CSS
I have defined my GridView header style in CSS. Because I've set my GridView to be sortable, so the header texts will be links, and it'll follow the style of Links as defined.
I'd like to change the header text color to fit to header row color, and finally I've found the solution.
Define the CSS like this:
tr.OrangeGridViewHeader,
tr.OrangeGridViewHeader a:visited,
tr.OrangeGridViewHeader a:link
{
background-color:#feaa66;
font-family:Verdana;
font-weight: bold;
color:#000;
text-decoration:none;
}
tr.OrangeGridViewHeader a:hover
{
background-color:#feaa66;
font-family:Verdana;
font-weight: bold;
color:#000;
text-decoration:underline;
}
Tuesday, January 8, 2008
Formatting link style using CSS
If you do not define the link style, by default, the link will always be underlined.
We can use CSS to format the style.
There are 4 selectors for links:
a:link | defines the style for normal unvisited links. |
a:visited | defines the style for visited links. |
a:active | defines the style for active links. A link becomes active once you click on it. |
a:hover | defines the style for hovered links. A link is hovered when the mouse moves over it. |
These are some of the styles I use:
Solid underlined link | |
No underlined link | |
Dotted underlined link |
I want my links to be underlined when they are at normal state, visited state and also active stated, but no underlined when mouse over it:
a:link, a:visited, a:active
{
color: #2666a6;
text-decoration:underline;
}
a:hover
{
color:#2666a6;
text-decoration: none;
}
If you want to have the dotted underlined links, you may declare it like this.
As there's no text-decoration as dotted underlined, so we make use of the bottom border.
a:link, a:visited, a:active
{
color: #2666a6;
text-decoration:none;
border-bottom:dotted 1px #2666a6;
}
a:hover
{
color:#2666a6;
text-decoration: none;
border-bottom:none;
}
Have fun!!
References: