
Custom Server Controls | 149
User and
Server Controls
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Custom schemas and Visual Studio annotations
As much as the metadata attributes described in the previous section help provide
support for the Blog control at design time, they’re missing one important piece:
IntelliSense support for adding tags and attributes in the HTML view of the Web
Forms editor. For developers who are more comfortable working in HTML than
in WYSIWYG style, this oversight is significant.
Since the HTML view of the Web Forms editor uses XSD schemas to determine
which elements and attributes to make available in a Web Forms page, to correct
the oversight, we need to implement an XSD schema that describes the Blog
control and the attributes that it supports. Optionally, we can add annotations to
the schema that tell Visual Studio .NET about the various elements and how we’d
like them to behave.
DataRow NewBlogDR;
NewBlogDR = BlogDS.Tables[0].NewRow( );
NewBlogDR["date"] = FormatDate(DateTime.Today);
NewBlogDR["title"] = TitleTB.Text;
NewBlogDR["text"] = BlogText.Text;
NewBlogDR["anchorID"] = Guid.NewGuid().ToString( );
NewBlogDR["email"] = _email;
BlogDS.Tables[0].Rows.InsertAt(NewBlogDR, 0);
BlogDS.WriteXml(Page.Server.MapPath("Blog.xml"));
Page.Response.Redirect(_addRedirect);
}
protected string FormatDate(DateTime ...