Hi Y'all,
I want to set an image (header) in my masterpage, i don't want to use design view because the image can change.
It works like this:
1protected void Page_Load(object sender, EventArgs e)2 {3//change the image4System.Web.UI.WebControls.Image masterImage;5masterImage = (System.Web.UI.WebControls.Image)6Master.FindControl("tssclogo");7if (masterImage !=null)8 {9 Session["masterpageurl"] ="~/img/logo.gif";10 masterImage.ImageUrl = Session["masterpageurl"].ToString();11 }12 }
But the problem is that i have to put this code in every page load of my content pages. Isn't there a way i only have to set this once?
Thanks in advance!
Why don't you use an usercontrol. Put that on the masterpage and let that handle the image...It slipped my mind... but why not using the onload event of the masterpage itself?
that's a nice idea!
I will have to work with 2 masterpages then because the userid only gets determined after authentication.
Thanks
You can work with one. Just check in the onpageload if the user is authenticated. If not, get the default image, otherwise the non-default...
0 comments:
Post a Comment