I am trying
to dynamically add RadButtons to a page by simply sticking the HTML in on the
page load. The buttons are not showing
up on the page. I have tried using
AddControl which does display the buttons, but after I call AddControl, I can
no longer modify the InnerHtml. Any
ideas how I can make this work? See Code
below.
protected void Page_Load(object sender, EventArgs e)
{
if (IsCallback)
return;
CompSubMenuDiv.InnerHtml = "";
int ItemNum = 0;
AddMenuHTML("Item Title 1",
"Item Description 1",
"~\\Comparison.aspx", "~\\Comparison.aspx", "~\\Comparison.aspx",
ItemNum);
AddMenuHTML("Item Title 2",
"Item Description 2.",
"~\\Comparison.aspx", "~\\Comparison.aspx", "~\\Comparison.aspx",
ItemNum);
}
protected void AddMenuHTML(string ModTitle, string ModDesc,
string LearnMoreURL, string SampleURL, string CreateIllURL,
int ItemNum)
{
// Add the html for one menu item.
ItemNum++;
string Button1Name = "RadButton" + Convert.ToString(ItemNum);
ItemNum++;
string Button2Name = "RadButton" + Convert.ToString(ItemNum);
CompSubMenuDiv.InnerHtml = CompSubMenuDiv.InnerHtml + "<br /><br /><br />" +
"<span class=\"SubMenuItemTitle IISMenuItemText1\">" + ModTitle + "</span><br />" +
"<div class=\"SysSubMenuLevel2Div\">" +
" <div class=\"SubMenuItemDescDiv\">" +
" <span class=\"SubMenuItemText\">" + ModDesc + " <a href=\"~\\comparisons.aspx\">learn more...</a> </span>" +
" <br />" +
" <telerik:RadButton ID=\"" + Button1Name + "\" runat=\"server\" " +
" Text=\"Show me a sample case...\"" +
" BorderColor=\"Black\" Height=\"1.5em\" ForeColor=\"#666666\" Style=\"padding-top: 2px; " +
" padding-bottom: 2px; margin-top: 0.5em; visible: true;\">" +
" </telerik:RadButton>" +
" </div>" +
" <div class=\"SubMenuCreateIllDiv\">" +
" <telerik:RadButton ID=\""+Button2Name+"\" runat=\"server\" " +
" Text=\"Create Illustration\" BorderColor=\"Black\"" +
" Height=\"1.5em\" Style=\"padding-top: 2px; padding-bottom: 2px; margin-top: 0.5em;" +
" float: right\" BackColor=\"Gray\" ForeColor=\"White\">" +
" </telerik:RadButton>" +
" </div>" +
"</div>";
}
protected void Page_Load(object sender, EventArgs e)
{
if (IsCallback)
return;
CompSubMenuDiv.InnerHtml = "";
int ItemNum = 0;
AddMenuHTML("Item Title 1",
"Item Description 1",
"~\\Comparison.aspx", "~\\Comparison.aspx", "~\\Comparison.aspx",
ItemNum);
AddMenuHTML("Item Title 2",
"Item Description 2.",
"~\\Comparison.aspx", "~\\Comparison.aspx", "~\\Comparison.aspx",
ItemNum);
}
protected void AddMenuHTML(string ModTitle, string ModDesc,
string LearnMoreURL, string SampleURL, string CreateIllURL,
int ItemNum)
{
// Add the html for one menu item.
ItemNum++;
string Button1Name = "RadButton" + Convert.ToString(ItemNum);
ItemNum++;
string Button2Name = "RadButton" + Convert.ToString(ItemNum);
CompSubMenuDiv.InnerHtml = CompSubMenuDiv.InnerHtml + "<br /><br /><br />" +
"<span class=\"SubMenuItemTitle IISMenuItemText1\">" + ModTitle + "</span><br />" +
"<div class=\"SysSubMenuLevel2Div\">" +
" <div class=\"SubMenuItemDescDiv\">" +
" <span class=\"SubMenuItemText\">" + ModDesc + " <a href=\"~\\comparisons.aspx\">learn more...</a> </span>" +
" <br />" +
" <telerik:RadButton ID=\"" + Button1Name + "\" runat=\"server\" " +
" Text=\"Show me a sample case...\"" +
" BorderColor=\"Black\" Height=\"1.5em\" ForeColor=\"#666666\" Style=\"padding-top: 2px; " +
" padding-bottom: 2px; margin-top: 0.5em; visible: true;\">" +
" </telerik:RadButton>" +
" </div>" +
" <div class=\"SubMenuCreateIllDiv\">" +
" <telerik:RadButton ID=\""+Button2Name+"\" runat=\"server\" " +
" Text=\"Create Illustration\" BorderColor=\"Black\"" +
" Height=\"1.5em\" Style=\"padding-top: 2px; padding-bottom: 2px; margin-top: 0.5em;" +
" float: right\" BackColor=\"Gray\" ForeColor=\"White\">" +
" </telerik:RadButton>" +
" </div>" +
"</div>";
}