I need to run a javascript function from ASP.NET code behind AFTER the page is finished.
I have used this code so far, but it returns "undefined" because the hidden field is not populated with value when the javascript function is run.
What should I do? Thanx in advance.
Aspx:
<asp:HiddenField runat="server" ID="ColorHiddenField" ClientIDMode="Static" Value="0" />
JavaScript:
function HandleColors() { alert($('#<%= ColorHiddenField.ClientID %>').val()); }
Code for:
ColorHiddenField.Value = item.Color; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "HandleColors();", true);
Payam sh
source share