Windows Scripting
  Home arrow Windows Scripting arrow Page 3 - Beginning SharePoint Web Part Development
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Beginning SharePoint Web Part Development
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 12
    2008-08-20

    Table of Contents:
  • Beginning SharePoint Web Part Development
  • Developing your first WSS 3.0 web part using Visual Studio 2008 extensions
  • A better web part with event handling: code
  • A better web part with event handling: explanation
  • Debugging a WSS 3.0 web part using Visual Studio 2008

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Beginning SharePoint Web Part Development - A better web part with event handling: code


    (Page 3 of 5 )

    The previous web part is a very simple web part which displays a simple message. Let us modify the previous web part to display two labels, two text boxes and a button in a table. Once the user clicks on the button, it should multiply both numbers and give the result in a new label.

    Modify your code in the web part so that it looks similar to the following:



    Option Explicit On

    Option Strict On


    Imports System

    Imports System.Runtime.InteropServices

    Imports System.Web.UI

    Imports System.Web.UI.WebControls

    Imports System.Web.UI.WebControls.WebParts

    Imports System.Xml.Serialization


    Imports Microsoft.SharePoint

    Imports Microsoft.SharePoint.WebControls

    Imports Microsoft.SharePoint.WebPartPages


    Imports System.Data

    Imports System.Data.SqlClient


    Namespace TestWebPart


    <Guid("68324554-9734-4813-958f-9301bcc7fe19")> _

    Public Class WebPart1

    Inherits System.Web.UI.WebControls.WebParts.WebPart


    Public Sub New()

    End Sub


    Protected Overrides Sub CreateChildControls()

    MyBase.CreateChildControls()


    Dim tbl As New Table

    Dim tRow1 As New TableRow

    Dim tRow2 As New TableRow

    Dim tRow3 As New TableRow


    Dim tR1C1 As New TableCell

    Dim tR1C2 As New TableCell

    Dim tR2C1 As New TableCell

    Dim tR2C2 As New TableCell

    Dim tR3C1 As New TableCell

    Dim tR3C2 As New TableCell


    tRow1.Cells.Add(tR1C1)

    tRow1.Cells.Add(tR1C2)

    tRow2.Cells.Add(tR2C1)

    tRow2.Cells.Add(tR2C2)

    tRow3.Cells.Add(tR3C1)

    tRow3.Cells.Add(tR3C2)


    tbl.Rows.Add(tRow1)

    tbl.Rows.Add(tRow2)

    tbl.Rows.Add(tRow3)


    Dim txtFirst As New TextBox

    txtFirst.ID = "txtFirst"

    Dim txtSecond As New TextBox

    txtSecond.ID = "txtSecond"

    Dim lblFirst As New Label

    lblFirst.Text = "Enter first:"

    Dim lblSecond As New Label

    lblSecond.Text = "Enter second:"

    Dim lblResult As New Label

    lblResult.ID = "lblResult"


    Dim btnSubmit As New Button

    btnSubmit.Text = "Submit"

    AddHandler btnSubmit.Click, AddressOf btnSubmit_click


    tR1C1.Controls.Add(lblFirst)

    tR1C2.Controls.Add(txtFirst)

    tR2C1.Controls.Add(lblSecond)

    tR2C2.Controls.Add(txtSecond)

    tR3C1.Controls.Add(btnSubmit)

    tR3C2.Controls.Add(lblResult)


    Me.Controls.Add(tbl)

    End Sub



    Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs)

    Dim i As Integer = CInt(CType(Me.FindControl("txtFirst"), TextBox).Text)

    Dim j As Integer = CInt(CType(Me.FindControl("txtSecond"), TextBox).Text)

    CType(Me.FindControl("lblResult"), Label).Text = "Product = " & CStr(i * j)

    End Sub


    Public Overrides ReadOnly Property Controls() As System.Web.UI.ControlCollection

    Get

    EnsureChildControls()

    Return MyBase.Controls

    End Get

    End Property

    End Class


    End Namespace


    More Windows Scripting Articles
    More By Jagadish Chaterjee


       · Hello guys,This is my first article in the series focusing on "sharepoint web...
       · Hello, I liked the article a lot, I followed it along and was able to create a web...
       · I have checked with different articles and thre were some comlexities in the...
       · Hi,with the help of your tutorial i have created and deploy the web part...
     

    WINDOWS SCRIPTING ARTICLES

    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...
    - Modifying XML Files in WSH
    - Reading XML Files in WSH
    - Visual Basic 2005 XML Programming Using XML ...
    - Creating an XML Document in WSH
    - Introducing Two-Way Data Binding using Silve...
    - Silverlight 2.0 Application Development with...
    - Burning Multisession CDs with IMAPI2 in WSH
    - Creating a Silverlight 2.0 Application that ...
    - Burning CDs with the IMAPI2 Control
    - Burning CDs in Windows XP with WSH

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT