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.
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.
Okay, it seems like someone has something to clean up.
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.
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:
public class WPT : WebPart {
protected ToolBar tlb;
protected override void CreateChildControls()
{
base.CreateChildControls();
tlb = (ToolBar)Page.LoadControl("/_controltemplates/ToolBar.ascx");
tlb.ID = "NavNodesTB";
tlb.Template_Buttons = new BtnTemplate();
Controls.Add(tlb);
}
protected override void Render(HtmlTextWriter writer)
{
RenderChildren(writer);
}
}
2) Create the BtnTemplate class that implements ITemplate interface. Add all the controls you want to show up on the toolbar
public class BtnTemplate : ITemplate
{
DropDownList ddlNumbers;
HyperLink tlBarLink;
void ITemplate.InstantiateIn(Control container)
{
tlBarLink = new HyperLink();
tlBarLink.ID = "idClickMeText";
tlBarLink.Text = "Click Me";
tlBarLink.ToolTip = "Click Me";
tlBarLink.NavigateUrl = "javascript:alert('Hello World!')";
ddlNumbers = new DropDownList();
ddlNumbers.ID = "idNumbers";
ddlNumbers.Load += new EventHandler(ddlNumbers_Load);
ddlNumbers.AutoPostBack = false;
container.Controls.Add(tlBarLink);
container.Controls.Add(ddlNumbers);
}
void ddlNumbers_Load(object sender, EventArgs e)
{
ddlNumbers.Items.Clear();
ddlNumbers.Items.Add(new ListItem("One"));
ddlNumbers.Items.Add(new ListItem("Two"));
ddlNumbers.Items.Add(new ListItem("Three"));
}
}
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.
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…
The Third Annual Toronto Code Camp is right upon us. This is the biggest community-driven event here in Toronto with the focus of delivering programming information and code that can immediately used by attendees. There is also a dedicated track for SharePoint which makes it even more fun to attend. I’m excited that I’ll not only attend this great event, but I’m also presenting one session in the SharePoint track.For more information and to register visit http://www.torontocodecamp.net.
Update: I am presenting the same topic as I did in our SharePoint User Group in Toronto on 16th of January 2008, but I have managed to change 50% of that presentation to be more code oriented with coverage of more topics related to FBA.