如何在 .NET 1.1 的 aspx 页面中内联访问 BCL 类或属性?
自从我在 ASP.NET 工作以来已经有一段时间了,自从在 .NET 1.1 工作以来也已经很长时间了。虽然我现在处于一个遗留应用程序中,但短期内无法升级,我需要修复一些硬编码值并将它们替换为 web.config 文件中的值。
这就是我所拥有的:
<asp:Image id=Image1 runat="server" ImageUrl='http://<%# ConfigurationSettings.AppSettings["CorporateRootUrl"] %>/media/images/spacer.gif' width="16" height="10" />
<img src='http://<%# ConfigurationSettings.AppSettings["CorporateRootUrl"] %>/media/images/spacer.gif' width="16" height="10" runat="server">
我更喜欢从我的 web.config 文件中获取底部示例,因为这是整个应用程序中使用的内容,这将使我的生活变得更加轻松。
如果我在后面的 .cs 代码中使用“CorporateRootUrl”值,我可以提取它,但这并没有真正帮助我。这段代码中有超过 2500 个地方需要更改。
我确信我错过了一些简单的东西,但我似乎无法弄清楚。
Its been a while since I worked in asp.net and a very long time since working in .NET 1.1. Here I am though in a legacy application that I can't upgrade for the short term, and I need to fix a number of hard coded values and replace them with a value from my web.config file.
This is what I have:
<asp:Image id=Image1 runat="server" ImageUrl='http://<%# ConfigurationSettings.AppSettings["CorporateRootUrl"] %>/media/images/spacer.gif' width="16" height="10" />
<img src='http://<%# ConfigurationSettings.AppSettings["CorporateRootUrl"] %>/media/images/spacer.gif' width="16" height="10" runat="server">
I would PREFER to get the bottom example to pull from my web.config file, since that is what is used throughout this application, and it would make my life a ton easier.
I can pull the "CorporateRootUrl" value if I use it in the .cs code behind, but that doesn't really help me. I have over 2500 places I need to change in this code.
I am SURE I am missing something simple, but I just can't seem to figure it out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
内联代码中的 # 和 runat=server 是让你绊倒的简单东西。
对你来说幸运的是,我打开了一个旧的 1.1 项目可以参考。我们没有做你需要做的同样的事情,但我的 1.1 也生锈了,查看代码可以帮助我找回一些东西。
祝你余下的任务顺利!
Try this:
The # in your inline code, and the runat=server were the simple things tripping you up.
Fortunately for you, I had a old 1.1 project open that I could reference. We weren't doing the same thing as you need to, but my 1.1 is rusty too and looking at the code is helping me get some of it back.
Good luck with the rest of your assignment!