TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
andrew slaughter
NA
33
0
change alt text on image and link href
Oct 15 2010 6:32 AM
Hi all
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 <img doesnt have a closing </img it cant find it.
for the images i did think about changing the <img tags to <asp:Image tags if this would help
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 </img>
}
}
}
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
Reply
Answers (
2
)
Lookup table
Prevent this "Internet Explorer needs to resend the information you've previously submitted" Dialog box from popping when i refresh my page