---
title: "Change server side control's value in javascript function"  
description: "Change server side control's value in javascript function"  
author: "Anonymous User"  
published: 2014-08-29  
updated: 2014-09-01  
canonical: https://www.mindstick.com/forum/2202/change-server-side-control-s-value-in-javascript-function  
category: "javascript"  
tags: ["javascript", "jquery", "server side control", "Change server side control's value in javascript", "Change server side control's value", "change value of server side control with javascript"]  
reading_time: 1 minute  

---

# Change server side control's value in javascript function

I want to set [Label](https://www.mindstick.com/articles/12835/print-label-tracking-how-do-these-features-make-auspost-woocommerce-plugin-better)'s text in [javascript function](https://www.mindstick.com/forum/2090/send-data-from-asp-dot-net-code-behind-to-a-javascript-function), function call and set text to Label and I see it but when I want to read Label's text from [code behind](https://www.mindstick.com/forum/2199/call-javascript-s-function-from-code-behind) the text is [previous](https://yourviews.mindstick.com/view/81421/unlock-2-0-is-just-like-previous-corona-lockdowns) text (for example if label's text is "5" and I set it to "10" in function but in code behind text is "5")

Javascript function

function PopUpFunction(code) {

$("#<%= lblStatus.ClientID %>").text(code);

return false;

}

Set function to [click event](https://www.mindstick.com/forum/424/how-to-call-form_paint-event-on-button-click-event) of [LinkButton](https://www.mindstick.com/forum/2100/linkbutton-to-expand-gridview-causes-row-colors-from-function-to-be-lost)

lnk.Attributes.Add("[onclick](https://www.mindstick.com/forum/12718/onclick-for-hyperlink)", "PopUpFunction(10);");

## Replies

### Reply by Sumit Kesarwani

You have used text as property but it is a [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server), Use text() not text

$("#<%= lblStatus.ClientID %>").text(code);

Put an alert to check if your page is refreshed or redirected

```
function PopUpFunction(code) {  $("#<%=lblStatus.ClientID %>").text(code);  alert($("#<%=lblStatus.ClientID %>").text());}
```

You can try returning false to stop postback.

lnk.Attributes.Add("onclick", "return PopUpFunction(10);");

```
function PopUpFunction(code) {  $("#<%=lblStatus.ClientID %>").text(code);  alert($("#<%=lblStatus.ClientID %>").text());  return false;}
```


---

Original Source: https://www.mindstick.com/forum/2202/change-server-side-control-s-value-in-javascript-function

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
