You need to turn someFunction (on the server) into a page method. Page methods can be called from client side code through AJAX calls.
Here is an article explaining such: http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/
Basically you decorate your method with the WebMethod and ScriptMethod attribute. Also, make it public:
[WebMethod, ScriptMethod]
public static void someFunction()
{
int test = 1;
test++;
}
These will require using statements for System.Web.Services and System.Web.Script.Services.
UPDATE: I just saw your updated question saying you are using .NET 2.0. If you cannot use Page Methods, here is a workaround. First, create a Generic HttpHandler. I called mine KillSession.ashx. Note you also have to implement the marker interface IRequiresSessionState to be able to access the HttpSession.
KillSession.ashx.cs:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.SessionState;
namespace TestFrames
{
/// <summary>
/// Summary description for KillSession
/// </summary>
public class KillSession : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
if (context.Session != null)
{
context.Session.Clear();
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
In your Default.aspx (frame container) add a function called killSession. Notice it calls KillSession.ashx:
<%@ Page Language="C#" AutoEventWireup="false" CodeBehind="Default.aspx.cs" Inherits="SimpleTest._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
function killSession() {
console.log("Killing Session");
$.ajax({
type: "POST",
url: "KillSession.ashx",
success: function () { alert("SUCCESS"); },
error: function () { alert("ERROR"); }
});
}
</script>
</head>
<frameset rows="20%,80%">
<frame name="Frame2" src="Frame2.aspx">
<frameset>
<frame name="Frame1" src="Frame1.aspx">
</frameset>
</frameset>
</html>
Then from your frames page (e.g. Frames2.aspx):
<script type="text/javascript">
if ('onbeforeunload' in window) {
window.onbeforeunload = (function () { clearSessionData(); });
} else {
if ('onunload' in window) {
window.onunload = (function () { clearSessionData(); });
}
}
function clearSessionData() {
alert("clearSessionData fired!");
if (typeof window.top.killSession === "function") {
window.top.killSession();
}
}
</script>
This will call the top level frame (Default.aspx) killSession function whenever there is an unload event within the frame.