Is it possible to set the value of a property inside the page class using jQuery? I know it’s possible to get the value in jQuery as long as the property is public but can’t seem to set the value.
This is the property in the code behind.
Private inventory_item_id As String = ""
Public Property InventoryItemId() As String
Get
Return inventory_item_id
End Get
Set(ByVal value As String)
inventory_item_id = value
End Set
End Property
<%=Me.InventoryItemId %> = 'some value'; isn’t working.
First things first, you should know that
<%=Me.InventoryItemId %>substitutes the actual value when the page is rendered (view source on the page in your browser you will see the id, say 1234, not a reference to the property). That being said, you could set the value of a hidden field on the client side which you could then read during postback and use to set your property. Note that the answer “no” is technically correct – the property no longer exists once the page has been rendered – but there is nothing stopping you from setting it again during the postback.In fact, your could make your property directly tied to a hidden field:
Which assumes that you have the following hidden field defined:
Finally, your jQuery could set the field with the following syntax (but this is just one of many, many ways it could be set):