There is an article on the Internet that describes how to add custom fields carefully. You may have seen this article. Here we will not detail how to create custom fields.
If you are interested, can you view another article on my blog http://blog.lickies.cn/Lists/Posts/ViewPost.aspx? Id = 17
----------------------------------------
Next, I will show you how to make a Treeview tree menu.
First modify the. ascx File
<% @ Control Language = "C #" DEBUG = "true" %>
<% @ Assembly name = "Microsoft. Sharepoint, version = 12.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c" %>
<% @ Register tagprefix = "SharePoint" assembly = "Microsoft. Sharepoint, version = 12.0.0.0,
Culture = neutral, publickeytoken = 71e9bce111e9429c "namespace =" Microsoft. Sharepoint. webcontrols "%>
<SharePoint: renderingtemplate id = "selectitemfromxmlfieldcontrol" runat = "server">
<Template>
<Asp: textbox id = "txt_ou" runat = "server"> </ASP: textbox>
<Asp: Treeview id = "treeview1" runat = "server" showlines = "true">
</ASP: Treeview>
</Template>
</SharePoint: renderingtemplate>
Modify the selectitemfromxml. fieldcontrol. CS File
Using system;
Using system. runtime. interopservices;
Using system. Web;
Using Microsoft. SharePoint;
Using Microsoft. Sharepoint. webcontrols;
Using system. Web. UI. webcontrols;
Using system. IO;
Using system. xml;
Using system. diagnostics;
Using system. directoryservices;
Namespace selectitemfromxml
{
[Clscompliant (false)]
[GUID ("eb269bd9-0d3e-4aa2-b88f-37fbccb0d7d8")]
Public class selectitemfromxmlfieldcontrol: basefieldcontrol
{
Protected Treeview treeview1;
Protected textbox txt_ou;
Protected override string defaulttemplatename
{
Get
{
Return "selectitemfromxmlfieldcontrol ";
}
}
Public override object Value
{
Get
{
Ensurechildcontrols ();
Return txt_ou.text;
}
Set
{
Ensurechildcontrols ();
Txt_ou.text = (string) This. itemfieldvalue;
}
}
Public override void focus ()
{
Ensurechildcontrols ();
Txt_ou.focus ();
}
Protected override void createchildcontrols ()
{
If (field = NULL) return;
Base. createchildcontrols ();
If (ControlMode = Microsoft. Sharepoint. webcontrols. spcontrolmode. Display)
Return;
Txt_ou = (textbox) templatecontainer. findcontrol ("txt_ou ");
Treeview1 = (Treeview) templatecontainer. findcontrol ("treeview1 ");
If (! Page. ispostback)
{
Treenode node2 = new treenode ();
Node2.text = "Quanzhou mobile ";
Treeview1.nodes. Add (node2 );
Getou ("ou = Quanzhou mobile", 10, node2 );
}
}
Protected void treeview1_selectnodechanged (Object sender, eventargs E)
{
}
Public void getou (string ouname, int amstr, treenode nodetmp)
{
// Obtain the ad object
// Search organization units
Directoryentry entry = new directoryentry ("LDAP: // sharepoint2007.qzit. com", "Administrator", "your password ");
// Obtain the subnode
System. directoryservices. directoryentry subentry = entry. Children. Find (ouname, "organizationalunit ");
// Loop the child object
Foreach (directoryentry res in subentry. Children)
{
If (res. Name. substring (0, 3) = "ou =") // you can determine whether the value is ou.
{
// Add a subnode
Treenode node2 = new treenode ();
Node2.text = res. Name. tostring (). Replace ("ou = ","");
Nodetmp. childnodes. Add (node2 );
// Recursive call
Getou (res. Name. tostring () + "," + ouname, 10, node2 );
}
}
}
}
}
The organizational unit of Quanzhou mobile must be established under the active node (the code can also be modified)