M
matthias s.
Hi there,
I'm building a usercontrol to provide language selection options. The
availabe languages are retrieved dynamically and should be shown as flags
(ImageButtons) in a table.
But I've got a problem with formatting the whole thing. I'm using
Response.Write statements to write the table. Here is a code snippet (the
fat logic is omitted and I hope the variable names are selfexplanatory):
+++
Language lng = new Language();
Response.Write("<table>");
for (int i = 0; i < Language.AvailableLanguages().Length; i++)
{
if (nRowCount == 0)
Response.Write("<tr>");
Response.Write("<td>");
string sImageFileName = "";
LanguageInfo linfo = Language.AvailableLanguages();
if (linfo.ID == lng.ID)
{
// language is selected
sImageFileName = "onflag_" + linfo.ShortCode + ".gif";
}
else
{
// not selected
sImageFileName = "offflag_" + linfo.ShortCode + ".gif";
}
// create an imagebutton control and set the properties
ImageButton btn = new ImageButton();
btn.ID = linfo.ShortCode;
btn.ImageUrl = "~/Lib/Images/" + sImageFileName;
btn.Click += new System.Web.UI.ImageClickEventHandler(btn_Click);
Controls.Add(btn);
Response.Write("</td>");
if (nRowCount == 3)
{
Response.Write("</tr>");
nRowCount = 0;
}
else
nRowCount++;
}
Response.Write("</table>");
+++
In the source of the resulting html page, I can't find any of the html I've
written with response write. The images are there, but none of the html.
How do I do this properly?
P.S.: If it matters, the LanguageSelectionControl (in who's Page_Load event
the above code is placed) is itself nested in a HeaderControl (as well my
own make).
Any hints are greatly appreciated!
/matthias
I'm building a usercontrol to provide language selection options. The
availabe languages are retrieved dynamically and should be shown as flags
(ImageButtons) in a table.
But I've got a problem with formatting the whole thing. I'm using
Response.Write statements to write the table. Here is a code snippet (the
fat logic is omitted and I hope the variable names are selfexplanatory):
+++
Language lng = new Language();
Response.Write("<table>");
for (int i = 0; i < Language.AvailableLanguages().Length; i++)
{
if (nRowCount == 0)
Response.Write("<tr>");
Response.Write("<td>");
string sImageFileName = "";
LanguageInfo linfo = Language.AvailableLanguages();
if (linfo.ID == lng.ID)
{
// language is selected
sImageFileName = "onflag_" + linfo.ShortCode + ".gif";
}
else
{
// not selected
sImageFileName = "offflag_" + linfo.ShortCode + ".gif";
}
// create an imagebutton control and set the properties
ImageButton btn = new ImageButton();
btn.ID = linfo.ShortCode;
btn.ImageUrl = "~/Lib/Images/" + sImageFileName;
btn.Click += new System.Web.UI.ImageClickEventHandler(btn_Click);
Controls.Add(btn);
Response.Write("</td>");
if (nRowCount == 3)
{
Response.Write("</tr>");
nRowCount = 0;
}
else
nRowCount++;
}
Response.Write("</table>");
+++
In the source of the resulting html page, I can't find any of the html I've
written with response write. The images are there, but none of the html.
How do I do this properly?
P.S.: If it matters, the LanguageSelectionControl (in who's Page_Load event
the above code is placed) is itself nested in a HeaderControl (as well my
own make).
Any hints are greatly appreciated!
/matthias