I'm in the process of writing a site for multi languages so all the content, href links and alt text for the images is stored in a db in the format
contentid countrycode pagecontent contenttype
all this data is info is then stored in a dataset which is looped through for each page using the code below. however I think I need to case the a href id into something but have no idea what and because the ![]()
for the images i did think about changing the ![]()
foreach (DataRow theRow in ds.Tables[0].Rows)
{
string control = theRow["ContentId"].ToString();
HtmlContainerControl ctrl = FindControlRecursive(this, control) as HtmlContainerControl;
if (ctrl != null)
{
//Response.Write(theRow["ContentType"].ToString());
//control.inn
//Object objControl = (Object)control;
//string control = "homeText";
//HtmlContainerControl
//HtmlContainerControl ctrl = FindControlRecursive(this, control) as HtmlContainerControl;
if (theRow["ContentType"].ToString() == "text")
{
ctrl.InnerHtml = theRow["PageContent"].ToString();
}
if (theRow["ContentType"].ToString() == "link")
{
//ctrl.HRef = theRow["PageContent"].ToString();
//ctrl.NavigateUrl = theRow["PageContent"].ToString();
//neither work
}
if (theRow["ContentType"].ToString() == "alt")
{
//never finds the control
//i believe its because and image tag isnt a proper htmlcontainercontrol
//because it has not
}
}
}
private Control FindControlRecursive(Control Root, string Id)
{
//if current control is the one to be searched for then return it
if (Root.ID == Id)
return Root;
//if not, call search on each sub control
foreach (Control Ctl in Root.Controls)
{
Control FoundCtl = FindControlRecursive(Ctl, Id);
//Bubble the located control back up to original call if it is found
if (FoundCtl != null)
return FoundCtl;
}
//if nothing is found and no sub controls remain then return null for this branch
return null;
}
thanks for any help or pointers
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
andrew slaughterPosted Oct 15, 2010, 7:55 AM
http://www.facebook.com/" target="_blank" id="facebookHref" runat="server">
i have both
Gomathi PalaniswamyPosted Oct 15, 2010, 7:43 AM
Let check the tag or text before