Showing posts with label view. Show all posts
Showing posts with label view. Show all posts

Thursday, March 22, 2012

Set Masterpage Image...

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...

Tuesday, March 13, 2012

Set pages encoding in code

A user can set the encoding his browser uses (In IE: View > Encoding).
I will show the page in the language the user selected (English or Japanes).
I do not want to create a seperate page for each language.
On the forms is some UserControls, with say menu's which i build in C# code, and I set the text of menu items according to the selected language.
The body of the page will be text extracted from the database in either English or Japanese.
Can one (should one?) set the page encoding in your code? I've seen that on the older asp pages, the developer set it to one value (en-jpn or sth like that...don't have access to the code as i'm typing), even though the page can be displayed in different languages, what l but sometimes a user have to go and manually set the encoding in his browser for the text to display correctly. (note : *Sometimes*)
Any suggestions what course to follow here?
It seems that with Chinese characters, on don't have problems, but Japanese is a bummer on it's ownGoogle for ResponseEncoding in ASP.NET.

BUT, I don't think that's the way it was meant to be/work. Shouldn't you be checking the language settings of the browser instead? (Tools > Options > languages)