get property from code behind into aspx page

前端 未结 5 1397
野性不改
野性不改 2021-01-14 08:33

Is it possible to get the property(get; set; ) say Name from code behind(aspx.cs) file into jquery?

5条回答
  •  佛祖请我去吃肉
    2021-01-14 08:35

    you can use a hidden input control and set the value of it inside the property. then you can access the value of the property by accessing the value of hidden variable.

    ex

    aspx page

    code behind

    Public Property MyProperty as String
    Get
       Return hiddenField1.Value
    End Get
    Set(value as string)
      hiddenField1.Value = value
    End Set
    

    jquery

    var hValue = $('#<%= hiddenField1.ClientID %>').val();
    

提交回复
热议问题