13.07.2015 Views

Microsoft SharePoint. Building Office 2007 Solutions in VB 2005 ...

Microsoft SharePoint. Building Office 2007 Solutions in VB 2005 ...

Microsoft SharePoint. Building Office 2007 Solutions in VB 2005 ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 10 ■ SHAREPOINT WEB PARTS 401Protected Overloads Overrides Sub RenderContents(ByVal writer As HtmlTextWriter)txtProperty.RenderControl(writer)writer.Write("")lblMessages.RenderControl(writer)End SubPublic Overloads Overrides Function ApplyChanges() As BooleanTryDim expression As Regex = _New Regex("\(\d\d\d\)\s\d\d\d-\d\d\d\d")Dim match As Match = expression.Match(txtProperty.Text)If match.Success = True ThenCType(WebPartToEdit, PhoneLabel).Phone = _txtProperty.TextlblMessages.Text = ""ElseCType(WebPartToEdit, PhoneLabel).Phone = _"Invalid phone number"End IfCatch x As ExceptionlblMessages.Text += x.MessageEnd TryReturn TrueEnd FunctionPublic Overloads Overrides Sub SyncChanges()TrytxtProperty.Text = CType(WebPartToEdit, PhoneLabel).PhoneCatchEnd TryEnd SubEnd ClassUs<strong>in</strong>g an Editor PartOnce you have created a custom editor part, you must associate it with a web part. This isaccomplished by overrid<strong>in</strong>g the CreateEditorParts method of the web part. When theCreateEditorParts method is called, you can create <strong>in</strong>stances of any editor parts you wantto load <strong>in</strong>to the property pane. After the editor parts are created, you must add them to anew EditorPartCollection and return the collection. List<strong>in</strong>g 10-16 shows a complete webpart for display<strong>in</strong>g a phone number with a custom format.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!