Asp.net controls, rendered with a variable
Date: 03/09/05
(Asp Dot Net) Keywords: html, web
This is probably something really stupid and simple I am doing wrong, but it has me stumped.
in my code behind (c#) I have a variable:
protected string dateRegex = "blah"; //lengthy regex with this weeks corp standard date expression (actually it is read from the web.config, but I have tried it as static for this example as well)
now, we have a custom control, that was already in place when I got my hands on, that I don't have access to modify freely at this time... it is a TextBox with a regex validator attached to it. It has a default regex expression, that I want to override... so I am trying it like this:
my problem is that this renders to html as a literal string, not as a server side variable:
in the span for the validator control, I see:
validationexpression="<%= dateRegex %>"
if I use the databinding syntax instead of the rendering (<%# dateRegex %>) it evals it as null, and uses the default expression I am attempting to override. it works correctly (overrides) if I paste the new expression into the variable on the control, but this defeats the purpose of having the expression in my web.config file so that it could be changed in just a single place (there are between 20 and 60 Date Text Boxes on this screen, depending on the user's permission level).
Ideas? (other than repairing the object itself so that it handles changes to the expression property correctly)?
Source: http://www.livejournal.com/community/aspdotnet/28399.html