tags:

views:

123

answers:

2

Is there any way to get the original text from a Asp:Label on a page, after the text has been altered?

with the orginal text i mean the text that is hard coded into the asp.net markup.

+3  A: 

There is no standard way to get it back after some chages, but you could do that in some your ways, for example add custom attributes to label

textLabel.Attributes.Add("data", textLabel.Text);

and then use it on your page. Or cache label value using js code on page startup or statically.

pocheptsov
A: 

Create a property that wraps the text assignment. Before the assignment take the current value and assign it to a hidden input or stick it in the session or viewstate.

Create a property that retrieves the previous value from the hidden input or session or viewstate.

Could get fancy and extend the label to add a PreviousValue property. Not sure how this would work in practice though.

rvarcher