I have an ID value that I'm saving to the ViewBag:
ViewBag.MyID = 1
I then want to use that ID within jQuery to check for something on the client side of my MVC application:
if (table.id === @ViewBag.MyID)
//Do stuff
This works fine, but the rendered HTML contains the actual ID:
if (table.id === 1)
//Do stuff
Is there any way to prevent this? I need to do this on the client side.
As per your requirement,what i understand is you don't want to display ID
value in rendered html output.
So to prevent this use Code Level Encryption/Decryption.
While sending the values to View encrypt them and compare.
--> I think it may help you. Thank You