pki15
July 8th, 2003, 10:31 AM
Hi, I'm working on learning to design web parts for the Sharepoint Portal Server. Web parts are essentially ASP.NET custom controls. My question is that I want the web part to display information from a database. Can I use my custom control, and when overriding Render, add more ASP.NET code(to access the database). Maybe the code will make my question more clear:
Imports System
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml.Serialization
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Utilities
Imports Microsoft.SharePoint.WebPartPages
< DefaultProperty("Text"), ToolboxData("<{0}:WebPart1 runat=server></{0}:WebPart1>"), XmlRoot(Namespace:="TestWebPart")> _
Public Class MyWebPart
Inherits WebPart
Protected Overrides Sub RenderWebPart(ByVal Output As HtmlTextWriter)
Output.Write(SPEncode.HtmlEncode( _
'Can I have the ASP.NET Code in here to display a database??
))
End Sub
End Class
I'm new to ASP.NET, so bear with me if this is a dumb question. If I can't do the code this way, is there another way to accomplish what I want? Thanks
Imports System
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml.Serialization
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Utilities
Imports Microsoft.SharePoint.WebPartPages
< DefaultProperty("Text"), ToolboxData("<{0}:WebPart1 runat=server></{0}:WebPart1>"), XmlRoot(Namespace:="TestWebPart")> _
Public Class MyWebPart
Inherits WebPart
Protected Overrides Sub RenderWebPart(ByVal Output As HtmlTextWriter)
Output.Write(SPEncode.HtmlEncode( _
'Can I have the ASP.NET Code in here to display a database??
))
End Sub
End Class
I'm new to ASP.NET, so bear with me if this is a dumb question. If I can't do the code this way, is there another way to accomplish what I want? Thanks