I am trying to call a Javascript from the codebehind but form some reason it is not working. Let me explain what i am trying to accomplish: when the page loads the system needs to check if this is the first time the user visit this page. if so a lightbox will open. So I created a javascript function in the page the onPageLoad i would like to call this function if it is necesary. This is what I have so far, looks pretty straight forward but it is not working. I will appreciate any help.
Here is the
html:
<form id="form1" runat="server">
<div>
<a id="OpenTutorial" href="../lightwindow/step1.html" params="lightwindow_width=450,lightwindow_height=470" class="lightwindow page-options">Open Tutorial</a>
</div>
<script>
function OpenTutorial() { $("#OpenTutorial").click() }
</script>
</form>
Code behind:
protected void Page_Load(object sender, EventArgs e)
{
//code to check if this is the first time
.....
// it this is the first time, call this function
Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "OpenTutorial()", true);
}
OpenTutorialfunction addalert($("#anc_OpenTutorial").length);as first line