I want to call a JavaScript function in codebehind. It is working fine on the button click event, not on the pageload event. As I can understand this is a Page Life Cycle's Get and post cause. Is there anyway i can get that javascript function on the page load event.
Html code :-
</asp:Label><asp:HiddenField ID="HiddenField1" runat="server" />
<script type="text/javascript" language="javascript">
try {
var i = 1000;
document.getElementById('<%= HiddenField1.ClientID %>').value = i;
}
catch (ex) {
alert(ex);
}
</script>
Code Behind :-
protected void Page_Load(object sender, EventArgs e)
{
try
{
string abc = HiddenField1.Value;
Label1.Text = abc;
Response.Write("asdfas" + abc);
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
}