Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I have a javaScript function Func() in my user control which updates hidden field value.
I would like to further SET this hiddenfield value to code behind property in a same javascript function (to access in parent aspx.vb page) to access in ASPX.VB without postback.

<script type="text/javascript" >

    function func(id) {

        HFTargetSign = id;
        alert(HFTargetSign);
    }
</script>



Can some one suggest me to implement this ?

Regards,
KV

What I have tried:

i have tried to assign property value in JavaScript, it is not working and gives error
Posted
Updated 26-Aug-18 19:47pm
Comments
Er. Puneet Goel 27-Aug-18 1:13am    
you have to use asynchronous call to update any server-side property.

1 solution

I'm not really sure if I follow you correctly but if you'd like to set a server-side property from JavaScript, then a HiddenField solution should work. For example, you can have a C# property like this:

C#
public string MyServerProperty
{
    get{ return HiddenField1.Value;}
    set{ HiddenField1.Value = value;}
}


Then you can set the value of the HiddenField in your JavaScript like this:

JavaScript
document.getElementById('<%=HiddenField1.ClientID%>').value = 'set whatever value here';
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900