Skip to main content

Posts

Showing posts from July, 2007

Element.xml explained

Some xml elements in Element.xml file in WSS 3.0: 1. Root element: Elements. It contains a Id attribute, which is a guid to uniquely identify this element. 2. Receivers element: This element is inside Elements. It contains ListTemplateId attribute which specifies what type of list will be attached to list item event handler. For example, a value of 101 means that the event handler will be attached to all document libraries. 3. Receiver element: This element is inside Receivers element. It contains several sub elements in it to define the class to receive list item event. A sample configure is like this: <receiver> <name>DigiDoc signature check event <type>ItemUpdated <sequencenumber>5000 <assembly>wssDigiDoc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=44b3223b8da05605 <class>wssDigiDoc.ddocEventHandler </> Name: A descriptive name Type: The event type that this receiver class will handle. The possible values are: ItemAdd, ItemUpdate, It

Features.xml explained

Some xml elements in Features.xml file in WSS 3.0: 1. Root element: Feature. It contains following attributes: Id: The guid to uniquely identify this feature. Title: The title of the feature appears in feature list Description: The descriptive text appears in feature list Version: Feature version number Scope: The scope this feature applies to. The possible values are: Web, Site, WebApplication and Farm Hidden: A boolean value to indicate if to show this feature in feature list xmlns: Xml namespace, always "http://schemas.microsoft.com/sharepoint/" ImageUrl: The image icon that appears at the left of the feature in feature list. The image should be in \IMAGES if no path is given. ReceiverAssembly: This is the full qualified assembly name that contains the event handler of feature installation/uninstallation, activation/deactivation. ReceiverClass: This is the class name in ReceiverAssembly that actually handles feature related events. This class must inherit SPFeatureReceiv

Users, AllUsers and SiteUsers

SPWeb object has three properties related to user collection: Users: The individual user added into site. This use does not belong to any site group. AllUsers: All the users in site group of this site, including both the individual users and the users in site groups. SiteUsers: All the available users in the site collection, including some hidden users added by WSS.

Change the field display color based on its value

This is tested on WSS 3.0. I have a custom list definition. There is a field called "Status" in this list definition. I want to change the display color of this field based on its value. Here is the steps: In the schema.xml file of this list, find the "Status" field definition. It should be inside /List/MetaData/Fields. Based on this field, create another Computed type field. Here is the code snippet: <Field Type="Text" DisplayName="Status" ReadOnly="TRUE" Required="TRUE" MaxLength="255" ID="{d9daabac-0014-4c1e-8c06-093ff0c7ecfc}" SourceID="{142fdfdd-7e46-4ca3-b9d3-56ae0ead646e}" StaticName="Status" Name="Status" ColName="nvarchar3" RowOrdinal="0" /> <Field ID="{0864C5F6-688C-4ee5-A4FE-3FB17CD5EE1E}" ReadOnly="TRUE" Type="Computed" Name="ColorStatus" DisplayName="Status" Dir="" DisplayNameS

Request URL

Example: http://localhost:8080/webapp/webform1.aspx?cmd=edit&UserName=John%20Smith Request.RawUrl: /webapp/webform1.aspx?cmd=edit&UserName=John%20Smith Request.Path: /webapp/webform1.aspx Request.PhysicalPath: D:\Web Dev\WebApp\WebForm1.aspx Request.BaseDir: /WebApp Request.Url.Host: localhost Request.Url.Port: 8080 Request.Url.Scheme: http Request.Url.CurrentDocument: WebForm1.aspx Request.Url.Query: ?cmd=edit&UserName=John%20Smith Request.Url.DisplayQuery: ?cmd=edit&UserName=John Smith Request.Url.AbsoluteUri: http://localhost:8080/webapp/webform1.aspx?cmd=edit&UserId=123 Request.Url.Authority: localhost:8080

Load .csv file into dataset

Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim file As String = "Test2.txt" Dim path As String = "C:\" Dim ds As New DataSet Try Dim f As System.IO.File If f.Exists(path & file) Then Dim ConStr As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _ path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\""" Dim conn As New OleDb.OleDbConnection(ConStr) Dim da As New OleDb.OleDbDataAdapter("Select * from " & _ file, conn) da.Fill(ds, "TextFile") End If Catch ex As Exception MessageBox.Show(ex.ToString) End Try DataGrid1.DataSource = ds.Tables(0) End Sub

Customize Trace in ASP.NET 2.0

By default, ASP.NET 2.o provides 3 trace listeners: DefaultTraceListener: Used in Visual Studio Environment TextWriterTraceListener: redirect tracing output to an instance of the TextWriter class or to any object that is a Stream class, such as a log file, network stream, or console EventLogTraceListener: redirect tracing messages to Windows event log You can derive your customized listener from these listeners or from the abstract base class TraceListener. There are several methods you can override, but the most important ones are Write and WriteLine. Trace configuration: Trace can be controlled using the configuration file. The following configuration has configured an event log trace listener. All the trace information will be routed to event log named EventLogName . <configuration> <system.diagnostics> <trace autoflush="true" indentsize="2"> <listeners> <remove name="Default"/> <add name="EventLogListener" typ