I am unable to found Page controls (Check boxes,Radio button,Images).
Please help me.my code is below.
HTML
<div id="divLeftpane" runat="server" class="product-left-menu"></div>
private void PopulateLeftSearchPane()
{
SearchDataContext objGetAspects = new SearchDataContext(CommonFunctions.getConnectionString());
var Aspects = from c in objGetAspects.RV_GetAspects()
select new
{
c.AspectName,
c.AspectID,
c.AspectContext,
c.AspectDescription,
c.AspectType
};
if (Aspects != null)
{
Button button = new Button();
foreach (var cn in Aspects)
{
HtmlGenericControl divgroupmenu = new System.Web.UI.HtmlControls.HtmlGenericControl("divgroupmenu");
divgroupmenu.Attributes.Add("class", "group-menu");
HtmlGenericControl divaccordionheading = new System.Web.UI.HtmlControls.HtmlGenericControl("divaccordionheading");
divaccordionheading.Attributes.Add("class", "accordion-heading");
HtmlAnchor hlheader = new HtmlAnchor();
hlheader.HRef = "#";
hlheader.InnerText = cn.AspectName;
divaccordionheading.Controls.Add(hlheader);
HtmlGenericControl divaccordioninner = new System.Web.UI.HtmlControls.HtmlGenericControl("divaccordioninner");
divaccordioninner.Attributes.Add("class", "accordion-inner");
ShowData(cn.AspectID, cn.AspectName,cn.AspectDescription, cn.AspectContext, cn.AspectType, divgroupmenu, divaccordionheading, divaccordioninner);
}
}
}
public void ShowData(Int64 AspectID, String strAspectName,String strAspectDescription, String strAspectContext, String strAspectType, HtmlGenericControl divgroupmenu, HtmlGenericControl divaccordionheading, HtmlGenericControl divaccordioninner)
{
Literal lculopen = new Literal();
lculopen.Text = String.Empty;
if (strAspectContext == "CHECK")
{
lculopen.Text = "<ul class="stone-type leftdrop">";
}
else if (strAspectContext == "OPTION")
{
lculopen.Text = "<ul class="ring-style leftdrop">";
}
else if (strAspectContext == "IMAGEMANY" && strAspectDescription.Contains("SEQURE"))
{
lculopen.Text = "<ul class="sequremultiple leftdrop">";
}
else if (strAspectContext == "IMAGESINGLE" && strAspectDescription.Contains("SEQURE"))
{
lculopen.Text = "<ul class="sequresingle leftdrop">";
}
else if (strAspectContext == "IMAGEMANY" && strAspectDescription.Contains("CIRCLE"))
{
lculopen.Text = "<ul class="circlemultiple leftdrop">";
}
else if (strAspectContext == "IMAGESINGLE" && strAspectDescription.Contains("CIRCLE"))
{
lculopen.Text = "<ul class="circlesingle leftdrop">";
}
else
{
lculopen.Text = "<ul class="stone-type leftdrop">";
}
divaccordioninner.Controls.Add(lculopen);
SearchDataContext objGetAspects = new SearchDataContext(CommonFunctions.getConnectionString());
var Aspects = from c in objGetAspects.RV_GetTraitValue(AspectID)
select new
{
c.AspectID,
c.TraitID,
c.ValueName
};
foreach (var cn in Aspects)
{
if (strAspectContext == "CHECK")
{
Literal lcliopen = new Literal();
lcliopen.Text = "<li>";
divaccordioninner.Controls.Add(lcliopen);
UpdatePanel myupdpnl = new UpdatePanel();
myupdpnl.ID = "upnl" + cn.AspectID + "_" + cn.TraitID;
CheckBox chk = new CheckBox();
chk.ID = "chktrait" + cn.AspectID + "_" + cn.TraitID;
chk.Text = cn.ValueName;
chk.Attributes.Add("AspectID", cn.AspectID.ToString());
chk.Attributes.Add("TraitID", cn.TraitID.ToString());
chk.AutoPostBack = false;
chk.Attributes.Add("onchange", "Javascript:return CallSearchResults('"+ chk.ID + "','" + cn.AspectID + "','" + cn.TraitID + "','" + cn.ValueName + "'" + ");");
myupdpnl.ContentTemplateContainer.Controls.Add(chk);
divaccordioninner.Controls.Add(myupdpnl);
Literal lcliclose = new Literal();
lcliclose.Text = "</li>";
divaccordioninner.Controls.Add(lcliclose);
}
else if (strAspectContext == "OPTION")
{
Literal lcliopen = new Literal();
lcliopen.Text = "<li>";
divaccordioninner.Controls.Add(lcliopen);
RadioButton rdbtn = new RadioButton();
rdbtn.ID = "rdbtntrait" + cn.AspectID + "_" + cn.TraitID;
rdbtn.Text = cn.ValueName;
rdbtn.AutoPostBack = false;
rdbtn.GroupName = "rdbtntrait" + cn.AspectID;
divaccordioninner.Controls.Add(rdbtn);
Literal lcliclose = new Literal();
lcliclose.Text = "</li>";
divaccordioninner.Controls.Add(lcliclose);
}
else if (strAspectContext == "IMAGEMANY")
{
Literal lcliopen = new Literal();
lcliopen.Text = "<li>";
divaccordioninner.Controls.Add(lcliopen);
HtmlAnchor htmlanchor = new HtmlAnchor();
Image img = new Image();
img.ID = "imgtrait" + cn.AspectID + "_" + cn.TraitID;
img.AlternateText = cn.ValueName;
htmlanchor.Controls.Add(img);
CommonFunctions objCommonFunctions = new CommonFunctions();
String StrAspectIDTraitID = cn.AspectID + "-" + cn.TraitID;
String imgtraitcons = CommonFunctions.searchImageFromBlob(StrAspectIDTraitID, objCommonFunctions.GetSystemVariables(CommonFunctions.SystemVariables.DataConnectionString), objCommonFunctions.GetSystemVariables(CommonFunctions.SystemVariables.traitconContainer));
img.ImageUrl = imgtraitcons;
divaccordioninner.Controls.Add(htmlanchor);
Literal lcliclose = new Literal();
lcliclose.Text = "</li>";
divaccordioninner.Controls.Add(lcliclose);
}
else if (strAspectContext == "IMAGESINGLE")
{
Literal lcliopen = new Literal();
lcliopen.Text = "<li>";
divaccordioninner.Controls.Add(lcliopen);
HtmlAnchor htmlanchor = new HtmlAnchor();
Image img = new Image();
img.ID = "imgtrait" + cn.AspectID + "_" + cn.TraitID;
img.AlternateText = cn.ValueName;
htmlanchor.Controls.Add(img);
CommonFunctions objCommonFunctions = new CommonFunctions();
String StrAspectIDTraitID = cn.AspectID + "-" + cn.TraitID;
String imgtraitcons = CommonFunctions.searchImageFromBlob(StrAspectIDTraitID, objCommonFunctions.GetSystemVariables(CommonFunctions.SystemVariables.DataConnectionString), objCommonFunctions.GetSystemVariables(CommonFunctions.SystemVariables.traitconContainer));
img.ImageUrl = imgtraitcons;
divaccordioninner.Controls.Add(htmlanchor);
Literal lcliclose = new Literal();
lcliclose.Text = "</li>";
divaccordioninner.Controls.Add(lcliclose);
}
else
{
}
}
Literal lculclose = new Literal();
lculclose.Text = "</ul>";
divaccordioninner.Controls.Add(lculclose);
divaccordionheading.Controls.Add(divaccordioninner);
divgroupmenu.Controls.Add(divaccordionheading);
divLeftpane.Controls.Add(divgroupmenu);
}
private void ProcessControls(Control ctrlContainer)
{
foreach (Control ctrl in ctrlContainer.Controls)
{
if (ctrl.GetType() == typeof(TextBox))
{
}
else if (ctrl.GetType() == typeof(CheckBox))
{
Response.Write(ctrl.UniqueID);
}
else if (ctrl.GetType() == typeof(RadioButton))
{
}
else if (ctrl.GetType() == typeof(Image))
{
}
if (ctrl.HasControls())
ProcessControls(ctrl);
}
}
protected void btnSearchResult_Click(object sender, EventArgs e)
{
ProcessControls(divLeftpane);
}