ASP.NET Server tags cannot contain <% ... %> constructs
Tags: asp.net c#We've all seen the Server Tags cannot contain <% ... %> constructs which comes from trying to use server side <% .. %> inside a server side control:
<asp:TextBox runat="server" Text="<%= ConfigurationManager.AppSettings["Title"] %>" />
You have a few ways around this, the easiest and most common way is to assign the properties server side:
this.textBox1.Text = ConfigurationManager.AppSettings["Title"];
But I like being able to do as much of my property setting in markup as possible so if I ever need to change the property it doesn't require a complete re-build/re-deploy.
The more elegant/fun solution would be to use an ExpressionBudiler, you've most likely used this class already if you've ever worked with a a multilingual website, to have controls pull globalized text from your resx resources you do the following:
<asp:Label runat="server" Text="<%$ Resources:Text, ParticipantHeader %>" />
This is using a ResourceExpressionBuilder, there is also an AppSettingsExpressionBuilder and a ConnectionStringsExpressBuilder built into the .NET framework that you can use. If these don't do what you want you can always build your own, you can see an example of a custom ExpressionBuilder at the MSDN Documentation.
Comments
Fantastic post! This could aid lots of people find out about this matter. Do you want to incorporate video clips together with these? It could undoubtedly help out. Your reason was spot on and owing to you; I probably won't have to describe everything to my pals. I can simply direct them here
Great Post. I would love to read more in future. keep up the good work. Yearly hosting http://www.intelweb.biz
Hello everybody. I have been searching the Internet for fun when I found your website. Terrific post. Thanks a ton for sharing your knowledge! It is encourging to know that some people still put in an effort into managing their websites. I'll be sure to check back again real soon.
Thanks for taking this opportunity to talk about this, I feel strongly about it and I benefit from learning about this subject. If possible, as you gain data, please update this blog with new information. I have found it extremely useful.
Great concepts on this webiste. It's rare these days to get sites with info you're trying to find. I am glad I discovered this website. I will actually bookmark it or perhaps subscribe to your rss feeds just to be updated on your new posts. Sustain the good work and I'm sure another folks looking for valued information will definitely stop by and benefit from your website for resources.
Can you email me back, please. Thank you.
i am quite often bumping throughout the online world nearly all of the time so I tend to read an awful lot, which isnt usually a good matter as many of the internet sites I view are made up of unnecessary waste copied from many other web pages a trillion times, on the other hand I have to compliment you because this blog is in actual fact readable and has a bit of genuine content, therefore cheers for breaking the trend of just copying other individual's websites, in case you ever want to take up a few hands of facebook poker together just gimme a shout - you have my email address :)
very nice. great post
Thanks for this useful blog. i found your blog on google and find it is very useful.
Impressive blog! Its not often that I comment but I felt you deserve it
I enjoy reading your site.
I had to refresh the page 2 times to view this page for some reason, however, the information here was worth the wait.
Pretty insightful post. Never thought that it was this simple after all. I had spent a good deal of my time looking for someone to explain this subject clearly and you’re the only one that ever did that. Kudos to you! Keep it up
It is refreshing post The particular information I discovered beneficial. We have bookmarked it and will come by for a second time subsequently. Regards.
Great blog post! I have bookmark this and subscribed to your RSs keep me update with your latest.