Code
Private void btn_listsearch_click (Object sender, eventargs E)
{
Stringbuilder sb = new stringbuilder ();
Spsite site = NULL;
Try
{
Site = new spsite(this.txt siteurl. Text );
Spweb = site.openweb(this.txt weburl. Text );
If (string.isnullorempty(this.txt listname. Text ))
{
Foreach (splist list in spweb. Lists)
{
SB. appendline (string. Format ("list name: {0 }:{ 1}", list. Title, list. Version ));
}
}
Else
{
Splist = spweb.lists+this.txt listname. Text];
SB. appendline ("[View Field ]");
Foreach (string fieldname in splist. defaultview. viewfields)
{
SB. appendline (string. Format ("field name: {0}", fieldname ));
}
SB. appendline ("\ r \ n [all fields ]");
Foreach (spfield field in splist. fields)
{
SB. appendline (string. Format ("[{0}]: {1}", field. Title, field. internalname ));
}
}
Textbox4.text = sb. tostring ();
MessageBox. Show ("finished execution! ");
}
Catch (exception ex)
{
MessageBox. Show (ex. Message );
}
Finally
{
If (site! = NULL)
{
Site. Dispose ();
}
}
}
Result Display