473,883 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need locale hyperlink help filename

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_windwa rd_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
Oct 1 '06 #1
10 2302
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******** *************** ***********@mic rosoft.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_windwa rd_dot_net
http://www.windwardreports.com

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


Oct 1 '06 #2
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******** *************** ***********@mic rosoft.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_windwa rd_dot_net
http://www.windwardreports.com

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


Oct 1 '06 #3
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_windwa rd_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******** *************** ***********@mic rosoft.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_windwa rd_dot_net
http://www.windwardreports.com

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


Oct 1 '06 #4
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_windwa rd_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******** *************** ***********@mic rosoft.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_windwa rd_dot_net
http://www.windwardreports.com

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


Oct 1 '06 #5
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
Thank you - this sounds perfect.

--
thanks - dave
david_at_windwa rd_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
Implemented & works great.

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

--
thanks - dave
david_at_windwa rd_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
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.we bcontrols
{

[AspNetHostingPe rmission(Securi tyAction.Demand , Level =
AspNetHostingPe rmissionLevel.M inimal),
AspNetHostingPe rmission(Securi tyAction.Inheri tanceDemand, Level =
AspNetHostingPe rmissionLevel.M inimal),
DefaultProperty ("File"),
ToolboxData("<{ 0}:HelpLink runat=\"server\ "/>"),
Designer(typeof (HelpLinkDesign er))
]
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_Toolt ip";

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

protected override void CreateChildCont rols()
{
Controls.Clear( );
Controls.Add(Ge tHelpImage());
}

protected virtual Control GetHelpImage()
{
Image img = new Image();
string text = GetHelpTooltip( );
img.AlternateTe xt = 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 GetDesignTimeHt ml()
{
StringWriter sw = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter( sw);
GetHelpImage(). RenderControl(w riter);
return sw.ToString();
}

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

// find the correct htm file
string locale = CultureInfo.Cur rentUICulture.I etfLanguageTag;
string root = Context.Request .PhysicalApplic ationPath + helpDir
+ File;
string filename = root + "-" + locale + ".htm";
while ((locale.Length 0) &&
(!System.IO.Fil e.Exists(filena me)))
{
int pos = locale.LastInde xOf('-');
if (pos 0)
{
locale = locale.Substrin g(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.Get GlobalResourceO bject(resourceF ile,
resourceName) as string;
}

protected override void OnPreRender(Eve ntArgs e)
{
this.Attributes .Add("title", GetHelpTooltip( ));
this.NavigateUr l = GetHelpFile();
this.Target = "_blank";

base.OnPreRende r(e);
}

}

public class HelpLinkDesigne r : ControlDesigner
{
public override string GetDesignTimeHt ml()
{
HelpLink hl = (HelpLink)this. Component;
return hl.GetDesignTim eHtml();
}

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
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_windwa rd_dot_net
http://www.windwardreports.com

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1736
by: Dynamo | last post by:
Not sure if this is a php or an html question but I'll post it anyway. I have multiple thumbnail images on my catalogue page catalogue.php and they are all hyperlinked to a single page called desc.php that will give an enhanced description of the product selected. I want the desc.php page to print the contents of a text file named ?.txt based on which image was clicked on in my catalogue page. example: if I click on 1.jpg in my...
2
2345
by: laura | last post by:
I am writing an intranet and want to be able to hyperlink to all files within a specific folder AND it's subfolders. Whilst I can hyperlink to the files in the specified folder AND I can also iterate through the subfolders and list them, for some reason I cannot hyperlink to the sub folders. I am writing this software at home using a computer that has IIS and Windows 98 and am accessing this as my server from another computer on my network....
0
3099
by: MJBAccess | last post by:
I'm trying to use a command button to print a Word document that is in a Hyperlink field. I keep getting Run-Time Error 5273 and it says the document name or path is not valid. The Hyperlink opens fine if I open it manually but not with this code. Any ideas? I'm Access 2002 with WinXP and all the latest updates. I do have Word Objects 10.0 selected under Tools Reference. Thanks, Mike Dim oApp As Object
4
4407
by: Marco Krechting | last post by:
Hi All, Sorry but I have to create new message since it cannot find the old message to send a reply. Coming back to this hyperlink thing I will try to explain the real problem cause I think we are going in circles. I have a continous form with a hyperlink field on it. Normally when you click on a hyperlink field Access will follow the Hyperlinkbase set in the database. This is for example in my case "I:\". However I have two different
3
4905
by: hermawih | last post by:
Please help . I want to load the contents of another rtf document by double-clicking the words . Chapter1.rtf Chapter2.rtf Chapter3.rtf ....
4
2225
by: Satya | last post by:
Hi all, The following code is throwing a run time error "The server tag is not well formed. " <ItemTemplate> <asp:HyperLink Runat="server" ID="lnkFile" NavigateUrl="javascript:OpenImage('<%# DataBinder.Eval(Container.DataItem,"FileName") %>');"><%#
2
4998
by: SAL | last post by:
I would like to create a VB.net function, that builds a dynamic hyperlink using System.Web.UI.WebControls.HyperLink, but I can not find any examples on how to generate a dynamic hyperlink. Has anyone done this before? I do not want to dynamically create my hyperlink on an ASP page, but rather a behind the scenes link that a user can paste into a Word document or Email, as an embedded link that points to a particular file. This would be...
24
3401
by: Donn Ingle | last post by:
Hello, I hope someone can illuminate this situation for me. Here's the nutshell: 1. On start I call locale.setlocale(locale.LC_ALL,''), the getlocale. 2. If this returns "C" or anything without 'utf8' in it, then things start to go downhill: 2a. The app assumes unicode objects internally. i.e. Whenever there is
0
1193
by: Matthias Huening | last post by:
Hi, I have problems using tkFileDialog under Linux (Ubuntu 8.04 in my case, but other Linuxes seem to show the same behaviour). The following works fine: import tkFileDialog f = tkFileDialog.askopenfilename()
0
9942
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11148
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10749
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10857
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7974
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5801
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5994
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4618
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3236
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.