Is there any way to change the value of a code behind property from JavaScript without using hidden-fields?
-
What you mean exactly by "code behind property"?user447356– user4473562012-10-09 11:54:12 +00:00Commented Oct 9, 2012 at 11:54
-
Code behind property means I have written a property on aspx.cs e.g. public bool IsConnected...Utkarsh– Utkarsh2012-10-09 13:21:52 +00:00Commented Oct 9, 2012 at 13:21
-
So AJAX is your only option, see the answer you already have for more details.user447356– user4473562012-10-09 13:46:33 +00:00Commented Oct 9, 2012 at 13:46
Add a comment
|
2 Answers
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>
1 Comment
Ewerton
I agree, you dont will change any "code-behind property" without postback. So, assuming you dont want a full postback, ajax is the solution.