开发者

How can I access a BCL class or property inline in a aspx page in .NET 1.1?

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' 开发者_如何学Gowidth="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.


Try this:

<img src="http://<% = ConfigurationSettings.AppSettings["CorporateRootUrl"] %>/media/images/spacer.gif" width="16" height="10">

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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜