2

Is there any way to change the value of a code behind property from JavaScript without using hidden-fields?

3
  • What you mean exactly by "code behind property"? Commented Oct 9, 2012 at 11:54
  • Code behind property means I have written a property on aspx.cs e.g. public bool IsConnected... Commented Oct 9, 2012 at 13:21
  • So AJAX is your only option, see the answer you already have for more details. Commented Oct 9, 2012 at 13:46

2 Answers 2

2

No it could not be done without sending request to server either by postback or ajax etc. This could help you sending request to server using jquery Ajax

If you want to change the value of some server control then it is possible with javascript.

In html

<asp:TextBox id="txtName" runat="server" ></asp:TextBox>

In javascript

<script type="text/javascript>
     txtName = document.getElementById('<%= txtName.ClientId %>');
     txtName.value = "changed";
     alert(txtName.value);         
</script>   
Sign up to request clarification or add additional context in comments.

1 Comment

I agree, you dont will change any "code-behind property" without postback. So, assuming you dont want a full postback, ajax is the solution.
1

I would say AJAX is the best answer for your problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.