Hi all

Im trying to create a site that is multi language, in order to do this all copy, alt tag text and url links are stored in a db.

I then get all the info for that language and put it into a cached dataset. i then loop through the dataset on each page look for a tag in the html code and enter the copy, image alt tag or url.

my code so far looks like this

foreach (DataRow theRow in ds.Tables[0].Rows){string control = theRow["ContentId"].ToString();HtmlContainerControl ctrl = FindControlRecursive(this, control) as HtmlContainerControl;if (ctrl != null){    if (theRow["ContentType"].ToString() == "text")    {    ctrl.InnerHtml = theRow["PageContent"].ToString();    }    if (theRow["ContentType"].ToString() == "link")    { //ctrl.HRef = theRow["PageContent"].ToString(); //doesnt work     }    if (theRow["ContentType"].ToString() == "alt")    {  //ctrl.Alt = theRow["PageContent"].ToString();  //doesnt seem to find the control and even if i hard code the the id in it doesnt work    }}}
foreach (DataRow theRow in ds.Tables[0].Rows)

{

string control = theRow["ContentId"].ToString();

HtmlContainerControl ctrl = FindControlRecursive(this, control) as HtmlContainerControl;

if (ctrl != null)

{

    if (theRow["ContentType"].ToString() == "text")

    {

    ctrl.InnerHtml = theRow["PageContent"].ToString();

    }

    if (theRow["ContentType"].ToString() == "link")

    {

    //ctrl.HRef = theRow["PageContent"].ToString();

    //doesnt work 

    }

    if (theRow["ContentType"].ToString() == "alt")

    {

    //ctrl.Alt = theRow["PageContent"].ToString();

    //doesnt seem to find the control and even if i hard code the the id in it doesnt work

    }

}

}

this works for putting the copy in but i cant get it to work for the url's or the image alt tags can anyone help

an example of my images are

<img class="socialIcon" src="/images/facebook.png" id="XfacebookIcon" runat="server" alt="Facebook icon" width="24" height="20" border="0" />

however i have tried putting my images like this if it will make my life easyer

<asp:Image ID="facebookIcon" runat="server" AlternateText="Facebook icon" ImageUrl="/images/facebook.png" CssClass="socialIcon" />

and an example of my href is this

<a href="http://twitter.com/" target="_blank" id="twitterHref" runat="server">

I also use this method to find the control

    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;         
    }

any help would be great thanks

use elementname.attributes.add(alt,"image");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.