Archive

Archive for January, 2008

Presenting at DevTeach/SQLTeach Toronto 2008

January 30th, 2008 27 comments

DevTech team has released the name of final speakers and their topics here and it seems that I also made the cut to speak at this event. DevTeach / SQLTeach Toronto 2008 will be the biggest developer, DBA and ITPro conference in Canada. It’s jam-packed with advanced sessions (level 300 and 400) all on the latest versions of Microsoft products and technologies. I am presenting two topics in the SharePoint track:

1) Accessing External Data Sources Through SharePoint:

Imagine that your SharePoint sites must contain structured data in a high volume and you need to perform complex queries and actions against it. Obviously, there are pros and cons of storing such information in SharePoint lists or in a custom SQL database. Realistically speaking, neither of these approaches alone nor Business Data Catalog (a.k.a BDC) is the answer to all of your data integration woes. You like the versioning, approval, bulk editing , rich UI and other good features that SharePoint lists offer but you are also concerned about the performance of your complex cross-list queries, CAML limitations (like ‘join’ , ‘Select distinct’) and optimized searching. You need to provide a common metadata repository and a hybrid framework for accessing external data sources through SharePoint utilizing all your options including BDC, Data View Web Part and custom code to keep both data structures in sync. In this session I will show you how you can surface information from your backend databases into your SharePoint sites, when to keep structured data in SharePoint lists and when not and eventually how in real world implementation you will end up combining all your options to come up with a robust solution with much better performance!

2) Forms based authentication in SharePoint with the SQL Server membership provide :

In ASP.NET 2.0 , there is an important concept called provider model which is used for many new feature such as Membership/Role Management, Profiles, etc. SharePoint is built on the top of ASP.NET 2.0 which means it can utilize everything that ASP.NET 2.0 offers including SQL Membership provider. In this session learn how to set this up, get yourself familiar with issues/workarounds, managing your custom profiles and finally how to leverage this solution for exposing your SharePoint sites to external users. This is an advanced session, targeting both IT Pros and Developers and attendees will receive fully commented source code with step-by-step walkthroughs for the exercises shown during demo.

Categories: General, MOSS 2007 Tags:

Possible Service Interruptions

January 29th, 2008 No comments

I am moving my entire site along with 3 customer sites to a new host this weekend. I am also adding some e-commerce components to be able to serve my customers better. Hopefully everything goes without a hitch, but there may be some service interruption next week.Once I make the move, I will have a nice story about how some of the web hostings rip off people. Regrettably, some people have no other options except to obey and accept their bullshits , but definitely that’s not the case for me. I am out of here Mr.Servergrid!

The address of my site and blog and also RSS feeds will not change.

Categories: General Tags:

Overly Hot Laptop

January 27th, 2008 No comments

I turn on my laptop and the fan starts to spin so fast, also my laptop gets so hot after a short period of time. I called the guy in customer service and he told me that is normal. He also says that laptops get hot and thats why the fan starts to work to cool it down ! Wow, I never knew what laptop fans are for 😉 Very informative phone conversation … I hung up!

I was not convinced so I decided to troubleshoot the issue myself. I opened up the case to have a peek. I noticed that there are so much dust around the fans. This doesn’t let the air to circulate well.

Before

Okay, it seems like someone has something to clean up.

After

I cleaned up the fan and surprisingly it fixed the problem. Yes, it is not a bad idea if sometimes you pick up the screw driver and try things out yourself.

Categories: General Tags:

Web Part with Toolbar

January 27th, 2008 10 comments

A web part that has its own toolbar with different controls added to it programmatically is easy to build.

1) Create a web part and override CreateChildControls and Render methods:

  1. public class WPT : WebPart {
  2. protected ToolBar tlb;
  3.  
  4. protected override void CreateChildControls()
  5. {
  6. base.CreateChildControls();
  7. tlb = (ToolBar)Page.LoadControl("/_controltemplates/ToolBar.ascx");
  8. tlb.ID = "NavNodesTB";
  9. tlb.Template_Buttons = new BtnTemplate();
  10. Controls.Add(tlb);
  11. }
  12. protected override void Render(HtmlTextWriter writer)
  13. {
  14. RenderChildren(writer);
  15. }
  16. }

2) Create the BtnTemplate class that implements ITemplate interface. Add all the controls you want to show up on the toolbar

  1. public class BtnTemplate : ITemplate
  2. {
  3. DropDownList ddlNumbers;
  4. HyperLink tlBarLink;
  5.  
  6. void ITemplate.InstantiateIn(Control container)
  7. {
  8. tlBarLink = new HyperLink();
  9. tlBarLink.ID = "idClickMeText";
  10. tlBarLink.Text = "Click Me";
  11. tlBarLink.ToolTip = "Click Me";
  12. tlBarLink.NavigateUrl = "javascript:alert('Hello World!')";
  13.  
  14. ddlNumbers = new DropDownList();
  15. ddlNumbers.ID = "idNumbers";
  16. ddlNumbers.Load += new EventHandler(ddlNumbers_Load);
  17. ddlNumbers.AutoPostBack = false;
  18.  
  19. container.Controls.Add(tlBarLink);
  20. container.Controls.Add(ddlNumbers);
  21.  
  22. }
  23.  
  24. void ddlNumbers_Load(object sender, EventArgs e)
  25. {
  26. ddlNumbers.Items.Clear();
  27. ddlNumbers.Items.Add(new ListItem("One"));
  28. ddlNumbers.Items.Add(new ListItem("Two"));
  29. ddlNumbers.Items.Add(new ListItem("Three"));
  30. }
  31. }

3) Finally,deploy your web part and you are pretty much done! Here is how your web part looks like.

Source Code can be downloaded here.

Update 13/Sep/2008:   Another way of adding toolbar is now documented here.

Categories: MOSS 2007 Tags:

FBA: Combining Stored Procedures and Power of CTEs

January 26th, 2008 No comments

Since I am a lazy developer I normally don’t like to author multiple stored procedures if I can afford to aggregate all the logic in one place without causing too much complexity. For example when working with custom authentication providers you are often required to write separate stored procedures for GetAllUsers, FindUsersByName, FindUsersByEmail that can be called from their counterpart overridden methods in your custom authentication provider’s code. Following example demonstrates how you can have one stored procedure that can handle GetAllUsers, FindUsersByName, FindUsersByEmail logic in one stored procedure. As shown below, @email and @username parameters can be null which means you can ignore these two filters and get all the users instead. One important thing to note is the table that holds all the user information in this example. It is called Contacts with ContactID as the primary key, but yours might be different! Read more…

Categories: MOSS 2007 Tags: