HtmlImage.Src not binding dynamically

A

alto

Hello,

I have a weird problem w/ a System.Web.UI.HtmlControls.HtmlImage control
(imgTitre in the code snippet below).
If not in a postback, I make a call to the following routine in the
Page_Load evt handler:

<code>
private void SetControls()
{
hpGoBack.Text = ((BasePage)Page).GetLocalizedText("button.GoBack");
lblNota.Text = ((BasePage)Page).GetLocalizedText("nota");

if ( Request["newsType"] != null )
{
switch ( int.Parse(Request["newsType"]) )
{
case (int)NewsGroup.Group.NewsReel :
BasePage.BuildURL( "images/titre_actualitesante.gif" );
lblNotaTxt.Text = ((BasePage)Page).GetLocalizedText("nota.NewsReel");
imgTitre.Src = BasePage.BuildURL( "images/titre_actualitesante.gif" );
break;

case (int)NewsGroup.Group.JobOffers :
lblNotaTxt.Text = ((BasePage)Page).GetLocalizedText("nota.JobOffer");
imgTitre.Src = BasePage.BuildURL( "images/titre_emploi.gif" );
break;

//default:
case (int)NewsGroup.Group.News :
lblNotaTxt.Visible = lblNota.Visible = false;
imgTitre.Src = BasePage.BuildURL( "images/titre_quoi.gif" );
break;
}
}
}
</code>

The page displays the image that imgTitre.Src points to correctly.
Next, in a button click (i.e. in a postback), I call the same routine again
and expect the same behaviour.
In the debugger I can see the value of imgTitre.Src is indeed the correct
one.
However, the end result is an empty image.
I tried replacing the HtmlImage w/ a System.Web.UI.WebControls.Image: again,
the image is empty.
It is empty even if I hardcode the path to the .gif file in the
SetControls() method above.
It only works if I hardcode the path to the .gif file in the aspx page, but
this is a nonsense, since in such a case I would have to implement 3
separate pages just to display the image statically.
So if someone has experienced something similar, please help me solve the
mystery!

TIA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top