i resolved my latest problem of accesing the active directory... since the same values are in my old project with the SQL database that's linked with the active directory but yeah... i have an error when i want to create an linkbutton array instead of a simple string list...
here is the code and where the error is located i narrowed it down as much as possible:
some people have this same bug with .net too...
[php]namespace FaceBook_app
{
public class FaceBook_Code : Microsoft.SharePoint.WebPartPages.WebPart
{
facebookDirectoryDataContext FBAccs = new facebookDirectoryDataContext();
Table<Badge> ACC;
List<Badge> Member;
//public LinkButton[] Test;
HtmlTextWriter writa;
public FaceBook_Code()
{
ACC = FBAccs.Badges;
Member = (from aws in ACC orderby aws.Bezoeker select aws).ToList();
//Test = new LinkButton[Member.Count];
}
protected override void CreateChildControls()//Problem #1 :: VAL = NULL @ <BR> (TRY/CATCH?)//#2 :: Object reference not set to an instance of an object. = (!no button eventhandler, Crashes when 1 codeline gets filled in, curently null entry?)
{
/*
try
{*/
LinkButton[] Test = new LinkButton[Member.Count];
for (int i = 0; i <= this.Member.Count - 1; i = i + 2)
{
Test[i].Click += new EventHandler(Test_Click);
Test[i].Text = Member[i].Bezoeker;
this.Controls.Add(Test[i]);
if (i + 1 < Member.Count)
{
Test[i].Text = Member[i].Bezoeker;
Test[i+1].Click += new EventHandler(Test_Click);
this.Controls.Add(Test[i + 1]);
}
else
{
try{}
catch(Exception a)
{
writa.WriteLine(a);
}
}
}/*
}
catch (*********enceException nre)
{
writa.WriteLine("EventHandler Creation failed");
writa.WriteLine(nre);
}*/
}
public override void RenderControl(HtmlTextWriter writer)
{
Add_Table(writer);
writer.Write("change val");
//================================================== ========
//------------------------[TESTING]-------------------------
//================================================== ========
try
{
for (int i = 0; i <= this.Member.Count - 1; i = i + 2)
{
try
{
//Test[i].Text = Member[i].Bezoeker;
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
Add_Subtable_Style(writer, 1);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
//writer.Write(Member[i].Bezoeker);
writer.RenderEndTag();//td
Add_Subtable_Style(writer, 1);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
if (i + 1 < Member.Count)
{
//Controls.Add(Test[i]);
//Test[i].Text = Member[i].Bezoeker;
//writer.Write(Member[i + 1].Bezoeker);
//Test[i].RenderControl(writer);
}
else
{
writer.Write("");
}
writer.RenderEndTag();//td
writer.RenderEndTag();//tr
}
catch (*********enceException b)
{
writa.WriteLine("Button Count Creation failed");
writa.WriteLine(b);
}
}
}
catch
{
writer.Write("EmptyControlCollection");
}
//================================================== ========
//---------------------[END - TESTING]----------------------
//================================================== ========
//writer.RenderEndTag();//tr
writer.RenderEndTag();//table
}
public void Test_Click(object sender, EventArgs e)
{
try
{
writa.WriteLine("Activated an button.");
}
catch(*********enceException nre)
{
writa.WriteLine(nre);
}
}
[/php]
this code works without any request for an button and without the childcontrolls. > childcontrols is the first line it fails.. says its NULL?? I added an Field == null statement... i now obtained the error:
[UnsafeControlException: Een webonderdeel of besturingselement voor een webformulier op deze pagina kan niet worden weergegeven of geïmporteerd. Het type is niet gevonden of staat niet als veilig geregistreerd.]
at Microsoft.SharePoint.ApplicationRuntime.SafeContro ls.GetTypeFromGuid(Guid guid)
at Microsoft.SharePoint.WebPartPages.SPWebPartManager .CreateWebPartsFromRowSetData(Boolean onlyInitializeClosedWebParts)
English:
[UnsafeControlException: An webpart or controlelement for an webform on this page can not be showed or imported. The type isn't found or isn't registered as safe.]
at Microsoft.SharePoint.ApplicationRuntime.SafeContro ls.GetTypeFromGuid(Guid guid)
at Microsoft.SharePoint.WebPartPages.SPWebPartManager .CreateWebPartsFromRowSetData(Boolean onlyInitializeClosedWebParts)
Last edited by Kuro Tenshi; 10-13-2010 at 02:22 AM.
@ Anime Section,Otaku/weeabo (orz.) @Graphics Section, Novice DigiArtist
neuest gift from Yura~Chan:
https://bakyurayuu.deviantar*****m/#/d372taw
2nd Place MOTM#9 Theme: CharMods - Combat Arms [No - Thanks] button
come on you know that don't want to push that ordinary button