Just little about C#, .NET, SQL Server, SharePoint and SAP

Archive for the ‘.NET Framework’ Category

about .NET Framework…

How to create a Visual Studio Item Template

Posted by zieglers on June 24, 2010

BACKGROUND:A number of predefined project and project item templates are installed when you install Visual Studio. You can use one of the many project templates to create the basic project container and a preliminary set of items for your application, class, control, or library. You can also use one of the many project item templates to create, for example, a Windows Forms application or a Web Forms page to customize as you develop your application.

In addition to the installed templates that are available in the New Project and Add New Item dialog boxes, you can access templates that you have created.

MOTIVATION:Developers are lazy. I don’t mean that in a bad way, but in the same way that a smart horse is a lazy horse. Developers just don’t stand for repeating the same tasks without finding a way to automate them. I count myself among the lazy developers. I’m quite willing to spend time figuring out how to automate those repetitive tasks that I find myself doing often.

Visual Studio provides enough extensibility points that I’ve made a new rule for myself: If I do the same task twice, I figure out how to automate it.

In this post, I’ll try to show you ‘How to create an Item Template‘ for your Visual Studio project.

This will allow you to take advantage of C#’s Item Templates to automate tasks that you find yourself having to perform on a regular basis.


Now, let’s assume we have an ‘Application Pages’ project. We’ve been creating some app pages for a while and now we’d like to automate this process.

Since creating an app page requires a number of steps, we don’t want to perform those steps again and again, so it’s time for an app page template for our project.

Before creating your item template, get your code in a position where it can be used as a template once it’s been generated by template. This means include all the tasks you repeat and only leave page specific code / logic. For that part of the code, simply you can use a comment saying: // YOUR CODE GOES HERE.

Ok, say you have your project item (you’ll create your template from) ready.

First, we start Export Template wizard from File menu.

Then, we choose Template Type. In our case, it’s ‘Item Template‘.

Next, we select the item we’d like to export as an item template.

Then, we select item references to include with our item.

Finally we name our item template, provide a custom icon for it if you want and a description.

Once you click finish, your item template will be generated. Solution and Item templates in Visual Studio are in ZIP format.

Now, let’s create an application page by using item template we’ve just created. For this, simply go to your project, right click where you want to add a new app page and select new item.

Select item template just created.

Provide a name for your app page and click Add. That’s all! Now a new app page has been created using your Item Template.

This concludes our post on ‘How to create an Item Template‘. Remember to give a second thought while coding, in case you find yourselves doing same thing more than once or twice, it might be a good candidate for an item template.



Posted in .NET Framework, C#, IT Stuff, SharePoint | Tagged: , , , | Leave a Comment »

Virtual vs. Abstract Classes

Posted by zieglers on March 25, 2010

Here is a brief comparison of VIRTUAL and ABSTRACT classes:


The virtual keyword is used to modify a method, property, indexer or event declaration, and allow it to be overridden in a derived class.

The abstract modifier can be used with classes, methods, properties, indexers, and events. Use the abstract modifier in a class declaration to indicate that a class is intended only to be a base class of other classes. Members marked as abstract, or included in an abstract class, must be implemented by classes that derive from the abstract class.

Abstract classes have the following features:
– An abstract class cannot be instantiated.
– An abstract class may contain abstract methods and accessors.
– It is not possible to modify an abstract class with the sealed (C# Reference) modifier, which means that the class cannot be inherited.
– A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors.

In general, virtual does not work on classes.
It is only for a class method, property, indexer or event declaration to have the possibility, to override them in a derived class.
An abstract class can’t be initiated and can more interpretated as a template of a class, which has to be derived to create an instance of it. 


Posted in .NET Framework, C#, IT Stuff | Tagged: , , , , , | 1 Comment »

Encrypt / Decrypt Connection Strings in web.config

Posted by zieglers on October 27, 2008

Key Maker

Key Maker

ASP.NET stores all the configuration information in plain text files called web.config and machine.config files. We store all vital information including database connection strings, user names, passwords for the databases. Thus you end up storing all sensitive information in vulnerable plain text files which is nothing but security compromise.

If you want to secure your connection strings and application settings, here is an easy way to encrypt / decrypt sections in web.config file. You can use aspnet_regiis.exe command line tool as follows:

Encrypting appSettings and connectionStrings sections in web.config :

Aspnet_regiis.exe –pef “appSettings” “<PathToWebSiteDir>” –prov “DataProtectionConfigurationProvider”

Aspnet_regiis.exe –pef “connectionStrings” “<PathToWebSiteDir>” –prov “DataProtectionConfigurationProvider” 

Decrypting appSettings and connectionStrings sections in web.config :

Aspnet_regiis.exe –pdf “appSettings” “<PathToWebSiteDir>”

Aspnet_regiis.exe –pdf “connectionStrings” “<PathToWebSiteDir>”


Posted in .NET Framework, IT Stuff | Tagged: , , , , , | Leave a Comment »

Using CreateUserWizard in MOSS Web Parts

Posted by zieglers on September 14, 2008

Using CreateUserWizard in normal ASP.NET .aspx pages can be very straightforward. However when you want to use it in web parts for MOSS, definitely there are some little details that you need to know to make it functional as expected.

First problem I had was related to MembershipProvider property. I provided AspNetSqlProvider as my provider name for that property value, and I get the ‘unexpected error’ page.. When I removed it, everything seemed to work ok. It was working all good for another sample project that i developed to test the usage of Form Authentication with CreateUserWizard.

Then, I realized that without providing MembershipProvider property, control was functioning as expected. This was because CreateUserWizard control, when membership info not provided, was inheriting this property’s value from the current MOSS web site’s web.config. So, if you want to use this control in a user control loader as a MOSS web part, you don’t need to provide MembershipProvider property.

Second problem that you may face, once the user is created successfully and page is redirected to the one you provided in ContinueDestinationPageUrl property, the page is being loaded with the recently created user’s credentials. Since you haven’t added this new user to your MOSS site, you’ll get Access Denied error. So, in order to resolve this issue, you need to set LoginCreatedUser property of the control to false, so that page is loaded with the original user’s credentials, not with the one’s recently created.

Also, if you want to check out a nice sample code on Login, Role and Profile usage in ASP.NET 2.0, you might want to read this post as well: http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx


Posted in .NET Framework, C#, IT Stuff, SharePoint | Tagged: , , , | Leave a Comment »

Exam 70-547: PRO: Designing and Developing Web-Based Applications by Using the Microsoft .NET Framework

Posted by zieglers on November 21, 2007


Today I passed Exam 70-547 : PRO: Designing and Developing Web-Based Applications by Using the Microsoft .NET Framework with a score of 1000/1000 🙂 There are 40 questions in the exam, no simulations. I even didn’t get any drag & drop question.

 … to be completed …

Posted in .NET Framework, C#, IT Stuff | 11 Comments »

After Exam: 70-528

Posted by zieglers on January 16, 2007

Exam Passed

Today I passed 70-528: TS: Microsoft .NET Framework 2.0 – Web-Based Client Development with a score of 965 again, just like the previous one, 70-536.

I was expecting to get 71 questions, however # of questions was 45. I guess, this varies from region to region. Looking at my score, I can say that I had again 2 wrong answers. I know one of it. Here is the other one that I’m suspicious about:

Q: You create a Web application. The Web application enables users to change fields in their personal profiles. Some of the changes are not persisting in the database. You need to raise a custom event to track each change that is made to a user profile so that you can locate the error. Which event should you use?

A. WebAuditEvent

B. WebEventManager

C. WebBaseEvent

D. WebRequestEvent

My answer was C. However, since WebAuditEvent is inherited from WebBaseEvent and in the question it is stated that a change tracking should be implemented, I thought WebAuditEvent might be more suitable. What do you think?

My next step in the certification step will be 70-431. Also if you know anything about ‘simulations’, I’ll be glad if you can share your knowledge. What are they? How simulation questions are answered? Things to consider while answering them…


Posted in .NET Framework, IT Stuff | 9 Comments »

Before taking Exam: 70-528 TS: Microsoft .NET Framework 2.0 – Web-Based Client Development

Posted by zieglers on January 12, 2007

Web Development 

… be prepared to come across 71 questions which have to be completed in 4 hours. Here are some highlights about the exam coverage:

7-8 questions were about deployment – Copy Web Tool, Publish Web Site …..

3-4 questions about WebParts,

6-7 for Mobile Applications,

2-3 about validations,

5-6 XML,

10-12 ADO.NET,

5-6 about custom and user controls,

5-6 for testing web apps,

10 for security – authentication, authorization, Login control…

and also some ambiguous questions as usual 🙂


Posted in .NET Framework, IT Stuff | 3 Comments »

Exam 70–536 : TS: Microsoft .NET Framework 2.0 – Application Development Foundation

Posted by zieglers on January 8, 2007


I want to write some comments about 70-536 exam. I got this exam today and passed with a score of 965 (over 1000). This means that I had 2 wrong answers out of 45 questions.

Firstly, I’d like to say that there are a lot of unambigious questions. I know, this is a general comment about Microsoft Certification Exams and you can come across this statement in many blogs. However, I’ll be more specific in this posting and point out some questions (splinters) in my mind.


Q.1. You need to write a multicast delegate that accepts a DateTime argument and returns a Boolean value. Which code segment should you use?

   A. public delegate int PowerDeviceOn ( bool, DateTime );

   B. public delegate bool PowerDeviceOn ( Object, EventArgs );

   C. public delegate void PowerDeviceOn ( DateTime );

   D. public delegate bool PowerDeviceOn ( DateTime );

I answered ‘C’ for this question. Could someone please explain me why ‘C’ is wrong?

( If you look at the Testking answer for this question, it says ‘A’! If ‘A’ is the right answer, why?!? )

 Q.2. You work as a developer at Company.com. You are creating an assembly named Company1. Company1 contains a public method. The global cache contains a second assembly named Company2.

You must ensure that the public method is only called from Company2. Which permission class should you use?

   A. GacIdentityPermission

   B. PublisherIdentityPermission

   C. DataProtectionPermission

   D. StrongNameIdentityPermission

I answered this as ‘A’. However, Testking guys say that the correct answer is ‘D’ with which i’m not satisfied. Could you also please share your comments on this one as well?! 🙂


My advise to the ones who’s gonna take the exam would be not to accept all Testking answers as correct. Make some research on questions whose answers seem wrong to you. Also share your concerns with others for sure! 😉 ( At least with the ones whose first aim is to LEARN, not to get certified! )


Posted in .NET Framework, IT Stuff | 49 Comments »