0

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

Arvind Ab
  • 25
  • 1
  • 8
  • Exactly what is this instance, and how are you sharing it? – John Saunders Oct 04 '14 at 17:11
  • it is a DateTime object. one of the asp pages sets it when the user clicks on a row in a grid view. and i want this datetime object stay intact untill it is used in a method in another asp page.its because if anoother client connects before this DateTime instance is used, the new client cant mess up this time. So the use get s wrong inf back – Arvind Ab Oct 04 '14 at 17:33
  • another thing id like to know is, if different clients connect to the asp page; Do they get their own thread to run on? I mena does the server creates a new thread for the new cleint with whole new instances? – Arvind Ab Oct 04 '14 at 17:37
  • 1
    Every _request_ gets it's own thread. How are you sharing this DateTime object? – John Saunders Oct 04 '14 at 17:51
  • here is the whole situation. 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 overrriden – Arvind Ab Oct 04 '14 at 18:28
  • First, please update your question with that information. Second, the "page method" only needs to be static if you use the old style WebMethod technique. If you create your services separate from your pages, using wither WCF or Web API, then you will not have this issue. – John Saunders Oct 04 '14 at 20:55
  • Also, it sounds like you should use session state. – John Saunders Oct 04 '14 at 20:56
  • tnx a lot. I finally found a way to call a non-static method from javascript. And i am using session state now. I just need to test the application where multiple clients connect to see whether data gets corrupted or not. and lastly ill update my question. Tnx a lot for help again – Arvind Ab Oct 05 '14 at 08:50
  • If you find an answer, then add an answer, not an update to your question. – John Saunders Oct 05 '14 at 18:23
  • @JohnSaunders Sorry, im not very familiar with the rules here :) – Arvind Ab Oct 05 '14 at 18:48
  • If you're not familiar with the rules, then you might look in the [help]. – John Saunders Oct 05 '14 at 18:49

1 Answers1

0

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)

Community
  • 1
  • 1
Arvind Ab
  • 25
  • 1
  • 8