asp:hyperlink 的目的是什么?资源文件中多少个字符串才算过多?

发布于 2024-12-27 16:42:04 字数 722 浏览 4 评论 0原文

我在 Visual Studio 中开发了一个(小型)公司网站,并且我沉迷于了解更多信息。我真的只有两个简单的问题,我无法谷歌。

1 - Asp:hyperlinks:

asp.hyperlink 的用途是什么?我知道我不能在我的资源文件中使用这些——我必须将它们全部转换回 html 链接。起初,asp:hyperlinks 看起来很复杂,所以我将所有链接都设置为 asp:hyperlinks。现在我又回来了。 asp:hyperlink(如果有的话)的用途是什么?

2 - 资源文件和字符串:

在本地化我的网站时,我发现我将 .master 资源文件 放在目录的 App_LocalResources 中创建文件夹 VS,因为您无法更改 .master 文件中的顶行内容并将文化/uiculture 放入其中。但我的所有常规 .aspx 页面都将进入根 App_GlobalResources 文件夹,进入 4 种语言资源文件之一(de、es-mx、fr、en)。我正在每个 .aspx 页面制作 2 或 3 个字符串。因此,当您的网站有 47 个页面时,资源页面上大约有 100 个字符串。

我刚刚从这个论坛和 MSDN 教程中了解了所有资源,所以我不得不问,因为这需要大量工作。这样可以吗?正常吗?我是否以错误的方式处理这个问题?

I developed a (small) company website in Visual Studio, and I'm addicted to learning more. I really just have two simple questions that I can't google.

1 - Asp:hyperlinks:

What is the purpose of an asp.hyperlink? I know I can't use these in my resource files -- I have to convert 'em all back to html links. At first, asp:hyperlinks looked sophisticated, so I made all my links asp:hyperlinks. Now I'm reverting back. What's the purpose of an asp:hyperlink, if any?

2 - Resource Files and strings:

In localizing my website, I have found that I'm putting the .master resource files in the directory's App_LocalResources folder VS created, because you can't change the top line stuff in a .master file and put a culture/uiculture in there. But all of my regular .aspx pages are going into the root App_GlobalResources folder into 1 of 4 language resource files (de, es-mx, fr, en). I'm making 2 or 3 strings per .aspx page. So when you have 47 pages in your website, that's about 100 strings on a resource page.

I just learned about all of the resources stuff from this forum and MSDN tutorials, so I have to ask, 'cause it's a lot of work. Is this okay? Is it normal? Am I going about this the wrong way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我一直都在从未离去 2025-01-03 16:42:04

我从未使用过资源,所以无法对此发表评论。

asp:hyperlink 和我所知道的标签之间的区别:

  1. asp:hyperlink 在输出到浏览器时被 ASP.NET 引擎转换为 A 标签。

  2. asp:hyperlink 可能会进行特定于浏览器的调整,以克服浏览器错误等。这是 ASP.NET 的要点,或者至少是其中之一。如果尚未包含在其中,则可以稍后添加它们,并且通过使用这些对象,您将在添加时/如果添加时获得它们。

  3. 两者都可以在代码隐藏中使用(您可以为 A 标记设置 runat="server"),但 asp:hyperlink 在大多数情况下具有更好的编译时检查 - 对更多项目的强类型转换与通用 两者都可以在代码隐藏

  4. asp:超链接更容易导致 HTML 膨胀,但前提是设计不佳。例如,很容易在它们上设置字体样式和颜色......但我不会,因为这会生成内联样式,与您手动或在 CSS 文件中所做的相比,这些样式通常相当臃肿。

  5. asp:hyperlinks 支持 TargetUrl (href) 的“~/Folder/File.ext”语法,如果您使用大量不同的 URL 和子文件夹并希望服务器处理映射,这在某些项目中非常有用以“智能”方式。

I've never used resources, so can't comment on that.

Differences between asp:hyperlink and a tag that I know of:

  1. asp:hyperlink is converted to an A tag by the ASP.NET engine when output to the browser.

  2. It is possible asp:hyperlink could make browser specific adjustments, to overcome browser bugs/etc.. which is kind of the point of ASP.NET, or at least one of them. If not already in it, they could be added later, and by using those objects you'll get that when/if added.

  3. Both can be used in code behind (you can set runat="server" for an A tag), but the asp:hyperlink has better compile-time checking in most cases -- strong type-casting for more items vs generic objects.

  4. asp:hyperlinks are easier to get HTML bloat, but only if used with a poor design. For example, it is easy to set font styles and colors on them.. but I wouldn't, since that generates in-line styles that are usually pretty bloated compared to what you would do by hand or in a CSS file.

  5. asp:hyperlinks support the "~/Folder/File.ext" syntax for the TargetUrl (href), which is nice in some projects if you use a lot of different URLs and sub-folders and want the server to handle mapping in a "smart" way.

情仇皆在手 2025-01-03 16:42:04

的目的是显示另一个网页的链接。

对于资源文件,由于您不是程序员而只是开发一个小程序,因此请使用您喜欢的东西。当您想要本地化您的 Web 内容时,资源文件对于初学者来说很容易使用 - 是的,如果需要,添加许多字符串是正常的。

The purpose of is to display a link to another webpage.

With the resource files, since you're not a programmer and just developing a small program, use something you're comfortable with. Resource files are easy to use for beginners when you want to localize your web content -- and yes, it's normal to be adding many strings if you need them.

终止放荡 2025-01-03 16:42:04

对于#1,

如果您想动态更改链接,则仅在一段文本上使用超链接控件将允许您在运行时访问该控件并操纵其内容,如果您有永远不会更改的静态链接,那么使用它会更简单纯文本,即

For #1

Using a hyperlink control over just a piece of text will allow you to access the control at runtime and manipulate its contents if you want to change the link dynamically, if you have static links that will never change then its simpler to just use plain text ie. <a href=''>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文