I’m using a label to store the Id of current item , being edited . and then use that to update item’s data .
is it possible for a user to change content of ,for example ,a label control’s content ? should I treat these controls just like a text box control’s input ?
how to stop this possibility ?
Edit : I mean should I validate label’s content just like input controls ? is it possible for a hacker to change content of label when posting back the page?
With the exception of normal
inputbased controls (such as<asp:TextBox>or<input type="checkbox">), controls that are changed dynamically on the client are not automatically updated back on the server on the postback… this would be the case with a<asp:Label>control.So you need to store those changes in an
inputbased control (maybe like a<asp:HiddenField>) using client side script, and then deal with them back on the server.UPDATE based on update to question.
The contents of the
<asp:Label>control is not posted back to the server inthe same way that a normal input control is.The content is carried through via the viewstate, and therefore even if somebody change the value of the label in the browser it would not be reflected in your code on the postback.