简体   繁体   中英

ASP.NET Get Original Text of Label

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM