By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,195 Members | 1,613 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,195 IT Pros & Developers. It's quick & easy.

need locale hyperlink help filename

P: n/a
Hi;

I have help html pages for each page of my ASP.NET webapp. So for the page
datasource.aspx, I have help\datasource.htm.

Bu what I want when the hyperlink is clicked, for it to look for the
following files in order (assuming I am running from the us):
help\datasource_en_US.htm
help\datasource_en.htm
help\datasource.htm

So that based on the client user's locale, I am getting them the best
language fit we have. Is there any easy way to do this? Or do I need to set
these in the page load?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
Oct 1 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Why dont you set the hyperlink instead to the correct URL based on their
country code, or have them all access the same help file when they click the
hyperlink and put logic in that to determine where to server.transfer them
onto, which could look for the correct local file if you had one prior to
doing the transfer.

Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
"David Thielen" <th*****@nospam.nospamwrote in message
news:1A**********************************@microsof t.com...
Hi;

I have help html pages for each page of my ASP.NET webapp. So for the page
datasource.aspx, I have help\datasource.htm.

Bu what I want when the hyperlink is clicked, for it to look for the
following files in order (assuming I am running from the us):
help\datasource_en_US.htm
help\datasource_en.htm
help\datasource.htm

So that based on the client user's locale, I am getting them the best
language fit we have. Is there any easy way to do this? Or do I need to
set
these in the page load?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


Oct 1 '06 #2

P: n/a
I believe, since you're making it a link, you'll have to do all the logic
for that first. There's no real way to have the link handle that itself.

Have you given some though though to using the built in globalization
features? Instead of having three seperate HTML files, you could create
resource strings and let the globalization feature try to figure out which
resource string to use based on the current user's culture selection and
simply dump that text into a literal control. That would really help you
avoid some messy logic for trying to figure out the link beforehand and pass
it off instead to the globalization features.
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"David Thielen" <th*****@nospam.nospamwrote in message
news:1A**********************************@microsof t.com...
Hi;

I have help html pages for each page of my ASP.NET webapp. So for the page
datasource.aspx, I have help\datasource.htm.

Bu what I want when the hyperlink is clicked, for it to look for the
following files in order (assuming I am running from the us):
help\datasource_en_US.htm
help\datasource_en.htm
help\datasource.htm

So that based on the client user's locale, I am getting them the best
language fit we have. Is there any easy way to do this? Or do I need to
set
these in the page load?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


Oct 1 '06 #3

P: n/a
Approach 1 is my present plan. But that means for every one of those links I
have to have code in my codebehind to determine the filename. I was hoping to
avoid that.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


"John Timney (MVP)" wrote:
Why dont you set the hyperlink instead to the correct URL based on their
country code, or have them all access the same help file when they click the
hyperlink and put logic in that to determine where to server.transfer them
onto, which could look for the correct local file if you had one prior to
doing the transfer.

Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
"David Thielen" <th*****@nospam.nospamwrote in message
news:1A**********************************@microsof t.com...
Hi;

I have help html pages for each page of my ASP.NET webapp. So for the page
datasource.aspx, I have help\datasource.htm.

Bu what I want when the hyperlink is clicked, for it to look for the
following files in order (assuming I am running from the us):
help\datasource_en_US.htm
help\datasource_en.htm
help\datasource.htm

So that based on the client user's locale, I am getting them the best
language fit we have. Is there any easy way to do this? Or do I need to
set
these in the page load?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


Oct 1 '06 #4

P: n/a
We do that in the aspx pages. But for the help.htm pages, the creation,
fromatting, etc. works som much better if for each language they just have a
bunch of pages and edit them. Because help_es.htm is pure Spanish so
resources just make creating it much more of a pain.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


"Mark Fitzpatrick" wrote:
I believe, since you're making it a link, you'll have to do all the logic
for that first. There's no real way to have the link handle that itself.

Have you given some though though to using the built in globalization
features? Instead of having three seperate HTML files, you could create
resource strings and let the globalization feature try to figure out which
resource string to use based on the current user's culture selection and
simply dump that text into a literal control. That would really help you
avoid some messy logic for trying to figure out the link beforehand and pass
it off instead to the globalization features.
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"David Thielen" <th*****@nospam.nospamwrote in message
news:1A**********************************@microsof t.com...
Hi;

I have help html pages for each page of my ASP.NET webapp. So for the page
datasource.aspx, I have help\datasource.htm.

Bu what I want when the hyperlink is clicked, for it to look for the
following files in order (assuming I am running from the us):
help\datasource_en_US.htm
help\datasource_en.htm
help\datasource.htm

So that based on the client user's locale, I am getting them the best
language fit we have. Is there any easy way to do this? Or do I need to
set
these in the page load?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


Oct 1 '06 #5

P: n/a
Hi David,

I suggest you create a custom server control inherited from LinkButton
which takes only one parameter - the page name; then it redirects to the
correct help file according to current thread's locale. (Better yet, since
your path pattern is determined, it can also guess the page name from
Request.Path, which means your developers don't need to specify any
parameters for the custom LinkButton, simply use it where a help link is
required)

Another approach is to use URL rewriting technique, but I think it's
overkill for your purpose:

#URL Rewriting with ASP.NET - The Code Project - ASP.NET
http://www.codeproject.com/aspnet/URLRewriter.asp

Let us know what do you think of all the suggestions so far.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 2 '06 #6

P: n/a
Thank you - this sounds perfect.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


"Walter Wang [MSFT]" wrote:
Hi David,

I suggest you create a custom server control inherited from LinkButton
which takes only one parameter - the page name; then it redirects to the
correct help file according to current thread's locale. (Better yet, since
your path pattern is determined, it can also guess the page name from
Request.Path, which means your developers don't need to specify any
parameters for the custom LinkButton, simply use it where a help link is
required)

Another approach is to use URL rewriting technique, but I think it's
overkill for your purpose:

#URL Rewriting with ASP.NET - The Code Project - ASP.NET
http://www.codeproject.com/aspnet/URLRewriter.asp

Let us know what do you think of all the suggestions so far.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 2 '06 #7

P: n/a
Implemented & works great.

Sample at
http://www.davidthielen.info/program...ile_link_.html

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


"Walter Wang [MSFT]" wrote:
Hi David,

I suggest you create a custom server control inherited from LinkButton
which takes only one parameter - the page name; then it redirects to the
correct help file according to current thread's locale. (Better yet, since
your path pattern is determined, it can also guess the page name from
Request.Path, which means your developers don't need to specify any
parameters for the custom LinkButton, simply use it where a help link is
required)

Another approach is to use URL rewriting technique, but I think it's
overkill for your purpose:

#URL Rewriting with ASP.NET - The Code Project - ASP.NET
http://www.codeproject.com/aspnet/URLRewriter.asp

Let us know what do you think of all the suggestions so far.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 21 '06 #8

P: n/a
Hi David,

Your code looks great. Thank you for sharing your code.

From your another post, it seems you're experiencing rendering errors at
design-time. The reason of this is because the default designer associated
with Hyperlink control (or other descendants that are inherited from
hyperlink that don't have specified other designers) will use the Render
method to render the html for design-time. Since we don't have HttpContext
at design-time, the code throws exceptions and the designer will notify you
that it cannot render the control at design-time.

Also, I think displaying the 16x16 image at design time would be
sufficient. This can be done by creating a custom designer for your control.

By the way, you don't have to manually construct the html in Render(). From
your code, it seems you're wrapping an image tag inside a hyperlink tag,
which can be represented a hyperlink control and an image control.

I've put together following code for your reference. Note that I've written
several methods as "protected virtual" which might be useful when your user
wants to inherit from your control and provide custom implementations for
those methods.

namespace net.windward.webcontrols
{

[AspNetHostingPermission(SecurityAction.Demand, Level =
AspNetHostingPermissionLevel.Minimal),
AspNetHostingPermission(SecurityAction.Inheritance Demand, Level =
AspNetHostingPermissionLevel.Minimal),
DefaultProperty("File"),
ToolboxData("<{0}:HelpLink runat=\"server\"/>"),
Designer(typeof(HelpLinkDesigner))
]
public class HelpLink : HyperLink
{
private const string bitmap = "images/help.gif";
private const string bitmapPixels = "16";
private const string helpDir = "help/";
private const string resourceFile = "windward";
private const string resourceName = "Help_Tooltip";

public virtual string File
{
get
{
string s = (string)ViewState["File"];
return (s == null) ? String.Empty : s;
}
set
{
ViewState["File"] = value;
}
}
public virtual string Bookmark
{
get
{
string s = (string)ViewState["Bookmark"];
return (s == null) ? String.Empty : s;
}
set
{
ViewState["Bookmark"] = value;
}
}

protected override void CreateChildControls()
{
Controls.Clear();
Controls.Add(GetHelpImage());
}

protected virtual Control GetHelpImage()
{
Image img = new Image();
string text = GetHelpTooltip();
img.AlternateText = text;
img.Width = Unit.Pixel(16);
img.Height = Unit.Pixel(16);
img.Attributes.Add("title", text);
img.BorderWidth = Unit.Pixel(0);
return img;
}

public virtual string GetDesignTimeHtml()
{
StringWriter sw = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(sw);
GetHelpImage().RenderControl(writer);
return sw.ToString();
}

protected virtual string GetHelpFile()
{
if (Context == null)
{
return "about:blank";
}

// find the correct htm file
string locale = CultureInfo.CurrentUICulture.IetfLanguageTag;
string root = Context.Request.PhysicalApplicationPath + helpDir
+ File;
string filename = root + "-" + locale + ".htm";
while ((locale.Length 0) &&
(!System.IO.File.Exists(filename)))
{
int pos = locale.LastIndexOf('-');
if (pos 0)
{
locale = locale.Substring(0, pos);
filename = root + "-" + locale + ".htm";
}
else
{
locale = string.Empty;
filename = root + ".htm";
}
}
// now we need the application path (for the url)
filename = File + (locale.Length 0 ? "-" + locale : "") +
".htm";
return filename;
}

protected virtual string GetHelpTooltip()
{
return HttpContext.GetGlobalResourceObject(resourceFile,
resourceName) as string;
}

protected override void OnPreRender(EventArgs e)
{
this.Attributes.Add("title", GetHelpTooltip());
this.NavigateUrl = GetHelpFile();
this.Target = "_blank";

base.OnPreRender(e);
}

}

public class HelpLinkDesigner : ControlDesigner
{
public override string GetDesignTimeHtml()
{
HelpLink hl = (HelpLink)this.Component;
return hl.GetDesignTimeHtml();
}

public override bool AllowResize
{
get
{
return false;
}
}
}
}

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 23 '06 #9

P: n/a
This is fantastic - thank you very much.

I added a couple of small changes and uploaded this latest to my blog and
put a thank you for you there too - I hope that is ok.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
Oct 23 '06 #10

P: n/a
Sure.

If you need anything else regarding this topic, please feel free to post
here.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 24 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.