I'm dynamically adding controls to my ascx.cs usercontrol and therefore I also need to dynamically execute javascript code from my ascx.cs usercontrol.
I'm executing my javascript using:
Page.ClientScript.RegisterStartupScript(typeof(Page), "reOpen", "<script type='text/javascript'> reOpenClick(); </script>")
This is my javascript in the ascx file
<%@ Register Assembly="obout_Window_NET" Namespace="OboutInc.Window" TagPrefix="obout" %>
<obout:Window runat="server" ID="ow_dialog" Width="200" Height="50"
Title="Open" IsModal="true" ShowCloseButton="true"
StyleFolder="~/Styles/obout/window/grandgray" VisibleOnLoad="false">
.
.
.
.
</obout:Window>
<script type="text/javascript">
function reOpenClick() {
ow_dialog.setTitle("Open");
ow_dialog.screenCenter();
ow_dialog.Open();
}
</script>
When running the code as usual I'm getting the error ReferenceError: ow_dialog is not defined
. But when typing reOpenClick() into the web browser's console everything runs fine.
Why am I getting the ReferenceError: ow_dialog is not defined
when typing in the function in the console works fine?