troubleshooting Question

Cannot call C# function on closing web page

Avatar of Nick_011
Nick_011Flag for South Africa asked on
Web Development
4 Comments1 Solution750 ViewsLast Modified:

I get the following error "Microsoft JScript runtime error: 'null' is null or not an object"
at this line when running the code below ;

I just need some way of calling a server C# function to dispose a few variables
when a user closes the form. I think the issue is with the master form however
all variations of  document.getElementById('btnHidden'); thatI've tried doesnt seam
to work

Any assistance would be appreciated

Kind regards
Nick 2008 Aspx
<%@ Page Theme="MainTheme" Language="C#"  MasterPageFile="~/Yyyyyy.Master"   . . . . .
. . . . . . . . . . . .. . . .. . . ..
<asp:Content ID="Content1" ContentPlaceHolderID="cphTitle" runat="server" >   

<asp:Content ID="Content2" ContentPlaceHolderID="cphBody" runat="server" >

<script type="text/javascript">

 window.onunload = ReleaseVariables()
 function ReleaseVariables ()
    var btn = document.getElementById('btnHidden');;



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

.  .  .  .  .  .  .  .  


    <asp:Label ID="Label1" runat="server" Text=""></asp:Label>

    <input type="button" id="btnHidden" value="button" onclick=btnHidden_Click/>


c# code behind
protected void btnHidden_Click(object sender, EventArgs e)
            if (dv != null) dv.Dispose();  
            if (dv2 != null) dv2.Dispose();
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros