Tuesday, December 9, 2008

Custom Verbs in your Webparts

Here I would shoud you how I added custom verbs in my custom webpart.

Override
WebPartVerbCollection
property in your webpart class and provide the following implementation

public override WebPartVerbCollection Verbs

{

get

{

WebPartVerb verb = new WebPartVerb("ExportToList", ExportToList); //New Verb

verb.Text = "Save Data to List"; //Text for Verb

WebPartVerb[] newVerbs = new WebPartVerb[] { verb }; //Add the verb into the array

//Add the array of verbs to the collection

WebPartVerbCollection verbs = new WebPartVerbCollection(base.Verbs, newVerbs);

return verbs;

}

}



Here First I am declaring new verb that we want, in the next line I am assigning Text to it.
Then I am declaring an array to contain this new verb and finally add this very to the base Verbs collection and return that collection.

When we declare verb, in the constructor second argument is the Handller event (e.g. ExportToList) which will be fired when this verb is clicked from your webpart.

We need to implement that Handler in our code and we can write actions which we want in that as given below:

public void ExportToList(object sender, WebPartEventArgs e)
{
// Add the logic to export this list
}


With above two implementations, when you deploy this webpart, you would see that verb in your webpart.

Cheers,


Steps for Setting up New Virtual Machine


- Install Virtual Server 2005 Software on the Host system
- Once installed, Open up Virtual Server Administrative Site from Programs
menu
- Create new Virtual Machine
1. Name it,
2. Set hardware config - RAM, Space, Network Adapters
- Insert Windows Server 2003 Installation Disk
O.S. Installation will proceed
- Keep on installing required Software on the virtual machine along with Service Packs needed.
- Setup the virtual machine to be in Domain

Note: Points to remember to Remote desktop to virtual machine
Control Panel > Add Hardware > Install the hardware that I manuall select from the list
From the list, Select Network Adapters, Next Select Microsoft as Manufacturer and from right select Loopback adapter. and proceed to Install.
Next go to Virtual Server Administrative site and configure your Virtual machine to add new Network adapter and restart the machine.

Now you should be able to login to the new virtual machine and start development.

Happy development..

Thursday, August 21, 2008

Developing MS Word AddIn

I have some posts in another blog which shows how to develop and putting functionalities to your COM AddIn for Microsoft Word 2003 using c# and .Net technology.

Posts are :

Post 1 : Prerequisites for AddIn
Post 2 : Creating an AddIn
Post 3 : Registry settings for AddIn
Post 4 : Debugging your AddIn
Post 5 : Custom Actions on AddIn


Please feel free to put comment on posts and share your experience.

Cheers,

Tuesday, August 12, 2008

Sorting and Searching in Generic List


Many times I have come across sorting a list or searching an object from list.
Here I am putting those code blocks that can help us to do so....

Sorting

List persons = PopulatePersonList();
//Sort A-Z
persons.Sort(delegate(Person x, Person y)
{
return x.Name.CompareTo(y.Name);
});

For Z-A sorting, we should use,
return y.Name.CompareTo(x.Name);


Searching

List persons = PopulatePersonList();
Person p =
persons.Find(delegate(Person x)
{
if (x.Name == "abc")
return true;
else
return false;
});

The above delegate implementation can also be replaced with static function call as shown below.

List persons = PopulatePersonList();
Person p = persons.Find(IsPersonInList);

private static bool IsPersonInList(Person x)
{
if(x.Name == "abc")
return true;
else
return false;
}

Yep ! That's It...

Happy Coding__

Wednesday, August 6, 2008

Virtual PC cannot find MSXML 6 - Error on Windows Vista


.... This is a "Hello World !!" kinda blog for me.


So Please wel come me in Blogging world.

To start with..

I had installed MS Virtual PC 2007 on my laptop having Windows Vista and when I tried running this Virtual PC, it prompted me :



As the error message complains, rather suggests I tried reinstalling Virtual PC and also installing MSXML 6 and tried again.

For many, trying as suggested above works fine. Not much Pain.
If you are among those many, this post ends here.

But for me, result the same Prompt. No luck. Strange (suggestions..)!!

Well, let's proceed....

After looking here and there for about an hour and trying above MS suggestions couple of times, at the end I came to know that there are two files missing in my File Strore in system. I found these two files in my collegues' system. and copied those at C:\Users\{username}\AppData\Roaming\Microsoft\Virtual PC on my laptop.

And Magic !!! It worked.

Those files are : VPCKeyboard.dll and Options.xml.

If you come across this than I wish you are lucky enough to have helpfull collegue around you to give these files. :)

Have a nice day !!

Happy coding__