Visual Basic SharePoint webpart (Template)

clock September 5, 2007 19:17 by author Fabian Tuender

In my search for a SharePoint template I could only find templates for C#. There was 1 project for Visual Basic but build with VS2002. I converted the project and rebuild it again in VS2005 and created some basic functions in it to show how you can use the webpart. I am just starting with SharePoint development after some years of visual basic 6 and .net hobby development so any comments welcome!

The webpart shows an htmlbutton, a text box, some text and a textbox with the value you set in the property of the webpart. When you push the Click me button the function Private Sub btnText_ServerClick is called. It will set the value of the textbox to your username.

 

When the webpart is created it will start by calling CreateChildControls() and RenderWebPart. In the render function it will write out the html to show on the webpart as well as it sets the value of the property field to the value you defined in your webpart properties.

 

Download the template or download the project.
To easy test the installation I installed VS2005 on a server together with WSS 3.0. After you build the project you can install the dll in the GAC by running the following command:
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\gacutil /i <path to your project>\ bin\Release\webparttemplate.dll


Update 8.9.2007: Okay; there was something I forgot to tell. You need to modify your web.config file to tell ASP .NET that your assembly is safe. By default the web.config file will be located in c:\Inetpub\wwwroot\wss\VirtualDirectories\80. The project contains a safecontrols.txt file, add the first line starting with <safecontrol to the SafeControls section of your existing web.config file. Add the second line (starting with <add assembly=) to the <assemblies> section.

Next run iisreset (Warning This will stop and start the web service, so its down for a few seconds and takes some more seconds after starting to load again)

The coding is shown below. Have fun with it, I hope it's helpful for your webpart development.
My information source Chapter 19: Beginning Web Part Development and Walkthrough: Creating a Basic SharePoint Web Part

           

Imports System.ComponentModel
Imports System.Web.UI
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.WebControls
Imports Microsoft.SharePoint.WebPartPages
Imports System.Runtime.InteropServices
Imports System.Web.UI.HtmlControls
Imports System.Xml.Serialization
       

<ToolboxData("<{0}:WebPartTemplate runat='server'></{0}:WebPartTemplate>"), XmlRoot(namespace:="Fabita"), Guid("C19B01AA-4593-4426-87BE-3B4194521CC2")> Public Class WebPartTemplate

Inherits WebPart      

Dim WithEvents btnTest As New HtmlButton
Dim lblDisplay As New HtmlInputText
Dim txtProperty As New HtmlInputText
       

Private Const _defPropertyText As String = "Your webpart property"
Private defPropertyText As String = _defPropertyText
       

<Browsable(True), Category("Web Part Template"), DefaultValue(_defPropertyText), WebPartStorage(Storage.Shared), FriendlyName("Your text"), Description("Your description of the friendlyname")> Public Property DisplayPropertyText() As String

Get
Return
defPropertyText
End Get
Set
(ByVal value As String)
defPropertyText = value
txtProperty.Value = value
End Set
End
Property

Private Sub btnText_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnTest.ServerClick
Dim user As SPUser = SPContext.Current.Web.CurrentUser
lblDisplay.Value = "Welcome " & user.Name
End Sub

Protected Overrides Sub CreateChildControls()
btnTest.InnerText = "Click me"
Controls.Add(btnTest)
lblDisplay.Value = ""
Controls.Add(lblDisplay)
txtProperty.Value = ""
Controls.Add(txtProperty)
End Sub

Protected Overrides Sub RenderWebPart(ByVal output As System.Web.UI.HtmlTextWriter)
btnTest.RenderControl(output)
lblDisplay.RenderControl(output)
output.WriteLine("<br>Your property")
txtProperty.Value = defPropertyText
txtProperty.RenderControl(output)
End Sub

End Class

VB WebPart.zip (17,42 kb)

WebPartTemplate Project.zip (432,65 kb)



Creating your SharePoint blog site

clock September 3, 2007 19:14 by author Fabian Tuender

When I wanted to start this blog I was wondering how I can remove this top navigation bar. The anonymous user should be limited with options, since most options apply only to users who have access to my site.

Searching the internet I found these posts: SharePoint Blogs Part I: Blog Access Control, Built-In Groups & Anonymous Users, SharePoint Blogs Part II: UI Customization and SharePoint Blogs Part III: Blogging from Word. They are great to get you started with modifying your site and start blogging from Word.

Next mission would be to find out how to modify the form that displays the comments in a post. You can now only enter a title and body but I want to extend that with a name, email, website and body. An option to remember your input would also be nice



Run.GPS Trainer UV RELEASE 2.0.1

clock September 3, 2007 19:09 by author Fabian Tuender

I love to use the Run.GPS software for training while cycling or running. After testing the old version and testing the new beta version; the final version is released. Check the website for more information. Happy training!



Dutch scanned manual for Run Tec Model 60331/KPPM 57

clock September 2, 2007 18:41 by author Fabian Tuender

Here is a scanned version of the Dutch manual for the Run Tec watch. If anybody knows an English link to the Model 60331/KPPM 57 manual, please let me know. There is a slight difference with the 60206 model. The battery cover is different as well as the names used in the menu's on the watch. The basic function still looks the same, just some small improvements.

Below are the separated pages in jpg format. You can also download the zip file containing all files.

Model 60331 - Dutch Manual - scan0000.jpg (1,11 mb)

Model 60331 - Dutch Manual - scan0001.jpg (1,26 mb)

Model 60331 - Dutch Manual - scan0002.jpg (678,24 kb)

Model 60331 - Dutch Manual - scan0003.jpg (997,02 kb)

Model 60331 - Dutch Manual - scan0004.jpg (789,30 kb)

Model 60331 - Dutch Manual - scan0005.jpg (922,26 kb)

Model 60331 - Dutch Manual - scan0006.jpg (961,47 kb)

Model 60331 - Dutch Manual - scan0007.jpg (763,52 kb)

Model 60331 - Dutch Manual - scan0008.jpg (847,11 kb)

Model 60331 - Dutch Manual - scan0009.jpg (1,01 mb)

Model 60331 - Dutch Manual - scan0010.jpg (1,13 mb)

Model 60331 - Dutch Manual - scan0011.jpg (820,44 kb)

Model 60331 - Dutch Manual - scan0012.jpg (805,81 kb)

Model 60331 - Dutch Manual - scan0013.jpg (1,04 mb)

Model 60331 - Dutch Manual - scan0014.jpg (900,98 kb)

Model 60331 - Dutch Manual - scan0015.jpg (831,94 kb)

Model 60331 - Dutch Manual - scan0016.jpg (729,66 kb)

Model 60331 - Dutch Manual - scan0017.jpg (293,38 kb)

Model 60331 - Dutch Manual - scan.zip (15,08 mb)





Sign in