I have a aspx page with UpdatePanel. In code-behind, I define a public var and function. The function use input date to calc the public var from database.
Public myRate As Decimal
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
CalcT.Attributes.Add("onchange", "cstgst();")
'......
GetTaxRates()
End Sub
Public Function GetTaxRates() As Boolean
//this function get user input date to calc the data from database
Dim mydate As DateTime = UI.GetDate(DateInput.Text) //UI.GetDate is a function to convert string to datetime
'....
End Function
In aspx page, I set the TextBox like:(AutoPostBack, inside UpdatePanel)
<asp:UpdatePanel>
<asp:TextBox ID="DateInput" runat="server" AutoPostBack="true" ></asp:TextBox>
</asp:UpdatePanel>
then I try to get myRate in javascript like:
function Test(){
var rate = '<%=myRate%>'
//....
}
At first time to load this page, I can get the right value for myRate. But when I modified DateInput with new date value, the postback is fired and the function GetTaxRates() did was called and the right value was set in myRate when debugging the code and checking the value. Problem is javascript can't get this new value. It always get the first time value.
How to reslove this problem?