How to protect a resource that is used by multiple ASP.NET pages?

80 Views Asked by At

I am working on a project that includes a parent page, This parent page includes two iframe tags that is connected to two other child asp pages. I need to protect a time instance, and it should be like this: In the first child page it should be locked, and when the other child asp page reads from it should be released. Can anyone give me an advice please?

[WebMethod]
    public static void SetCreatioTimeAndID(DateTime CreationTime, string ID)
    {
        ResourceProtector.Sem.WaitOne();
        SessionHelper.CreationTimeFromEvents = CreationTime;
        SessionHelper.EventID = ID;
    }

and here is the jquery function that calls on the method:

function EventGrid_ItemSelected(sender, e) {
        var item = e.get_item();
        var creationTime = item.Data[0][1];
        var id = item.Data[10];

        PageMethods.SetCreatioTimeAndID(creationTime, id, OnSuccess);
    }

    function OnSuccess(response, userContext, methodName) {
    }

Since the gridview(ComponentArt grid) im using doesnt have a server side event when a row is selecteddoesnt, i have to ouse a client side event, to retrieve the row is selected. then i call the server side function to store the Date of the row. If you like this is the whole scenario: when a user choses a row on the gridview i have to call a server function from a jquery function in the page. The problem is this server function has to be static. therfore i store it in a static DateTime object, so when the user presses a button, the information regarding that DateTime object is loaded. the problem is if another client connects to server and chooses a row, im afriad the DateTime objecdt is

1

There are 1 best solutions below

0
On

this link answered my question. This way i can call non-static methods on the server from javascript. Here is the link: Call non-static method in server side(aspx.cs) from client side use javascript (aspx)