Fulvio's Blog

.NET e dintorni

  Home :: Contact :: Syndication  :: Login
  84 Posts :: 3 Stories :: 5 Comments :: 3026 Trackbacks

Ecco a voi un primo esempio di webparts (molto semplice) scritta in VB.NET

 

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


<ToolboxData("<{0}:SimpleWebPartVB runat='server'></{0}:SimpleWebPartVB>"), _
Guid("D95AE857-C7C5-415d-A595-F18216BB41BD")> _
Public Class SimpleWebPartVB

Inherits WebPart

Dim WithEvents oButton As New HtmlButton()
Dim oTextBox As New HtmlInputText()
Dim oLabelZoneID As New HtmlInputText()




'Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
' output.Write([Text])
'End Sub

Private Sub oButton_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles oButton.ServerClick
Me.Title = oTextBox.Value
End Sub


Protected Overrides Sub CreateChildControls()
oButton.InnerText = "Set Web Part Title"
Controls.Add(oButton)

oTextBox.Value = ""
Controls.Add(oTextBox)

oLabelZoneID.Value = Me.ZoneID
Controls.Add(oLabelZoneID)

End Sub


Protected Overrides Sub RenderWebPart(ByVal output As System.Web.UI.HtmlTextWriter)
oTextBox.RenderControl(output)
oButton.RenderControl(output)
output.WriteLine("<br>")
oLabelZoneID.RenderControl(output)
End Sub
End Class
posted on martedì 14 giugno 2005 5.27