•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 423,719 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,146 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 22918 | Replies: 7 | Solved
![]() |
Hi Mr White Tiger, :-)
Thanks for your quick response.
Yes, this sends information to the server and not the server side script. Actually your code will try to load a new page from the URL specified but does not post back the calling aspx page or invoke an event in the Server side script. This is what I need.
Let me explain you the need (May be this will help you understand the Problem better),
Say you have an E-Mail service like Yahoo and hotmail. When a user logs into his account I will make an entry in the database saying that "User X has logged in will Blah blah ...Time...� This can be done through the Page load event.
If another user tries to login to the same E-mail Account. I should be able to throw him out saying "Get out Mr.Y...�
The problem that I am currently facing is that... I am not able to keep track of the first user, i.e., if he is still using the window or not. This cannot be done through the server side script because we do not have a page_UnLoad event in Aspx.
Work Around:
I can keep a Log out hyperlink where I can check if the user has logged out or not. But the problem is what if the user closes the window abruptly with out using the Log out Hyperlink (you see there are few stinking users).
Our JavaScript will help us in this issue. It has a unload system function which when declared in the Body tag will be triggered when the page Closes. (This is simply fast)
But I am not able to send the information from the JavaScript to the database to remove the user’s record from the database. SO I have to call a server side event (or a postback to the calling page) to update the database. AND this is where I need your help.
Hope it make sense.
I know this mail is toooo Long. Kindly bare ;-)
Thanks,
NaveenChander
Thanks for your quick response.
Yes, this sends information to the server and not the server side script. Actually your code will try to load a new page from the URL specified but does not post back the calling aspx page or invoke an event in the Server side script. This is what I need.
Let me explain you the need (May be this will help you understand the Problem better),
Say you have an E-Mail service like Yahoo and hotmail. When a user logs into his account I will make an entry in the database saying that "User X has logged in will Blah blah ...Time...� This can be done through the Page load event.
If another user tries to login to the same E-mail Account. I should be able to throw him out saying "Get out Mr.Y...�
The problem that I am currently facing is that... I am not able to keep track of the first user, i.e., if he is still using the window or not. This cannot be done through the server side script because we do not have a page_UnLoad event in Aspx.
Work Around:
I can keep a Log out hyperlink where I can check if the user has logged out or not. But the problem is what if the user closes the window abruptly with out using the Log out Hyperlink (you see there are few stinking users).
Our JavaScript will help us in this issue. It has a unload system function which when declared in the Body tag will be triggered when the page Closes. (This is simply fast)
But I am not able to send the information from the JavaScript to the database to remove the user’s record from the database. SO I have to call a server side event (or a postback to the calling page) to update the database. AND this is where I need your help.
Hope it make sense.
I know this mail is toooo Long. Kindly bare ;-)
Thanks,
NaveenChander
Yo FISH(I dont know the name of the fish but I remember seeing something similar in National Aquarium in Washington DC) ;-)
Its good you said your purpose in detail,your first post lacked description.
I had to do something similar, a couple of months ago.But my luck I used a frameset.It was intended for a different purpose(The client wanted me to hide the URL) but it really helped for passing values from javascript to server side scripting.
I used something like this whenever I wanted to execute something on the server side from a javascript.
window.open(""default.aspx?f=1"" ,""mainframe"");
On the server side I checked for value of f and executed some database code.
Since the Javascript is client - side and VB.NET or C#.NET is Server side script, I dont think you can call server side codes from inside Javascript.
There is always a workaround.
Somebody here might help you on that.
Its good you said your purpose in detail,your first post lacked description.
I had to do something similar, a couple of months ago.But my luck I used a frameset.It was intended for a different purpose(The client wanted me to hide the URL) but it really helped for passing values from javascript to server side scripting.
I used something like this whenever I wanted to execute something on the server side from a javascript.
window.open(""default.aspx?f=1"" ,""mainframe"");
On the server side I checked for value of f and executed some database code.
Since the Javascript is client - side and VB.NET or C#.NET is Server side script, I dont think you can call server side codes from inside Javascript.
There is always a workaround.
Somebody here might help you on that.
Save White Tiger
Frameset
With frameset, you can display more than one webform in the same browser window. Each frame is independent of the others.
Disadvantages:
1.Its a mess when you try tuning your frameset for different screen resolution.
2.Each browser has some compactibility issue,but I can be solved easily
3.The web developer must keep track of more webforms.
4.It is difficult to print the entire page.
Advantages:
1.Its really easy to use.
2.You can invoke a server script from a Javascript.
For my application I had three frames.
1.Logo
2.Left frame
3.Right frame
The Logo webform is my secret hide out.I have some hidden server side codes.
The left frame had various buttons like,
1.compose
2.edit profile
3.Signout
4.bla
5.bla bla
when the user clicks these buttons,for example edit profile
I'll executed the server script for calling the corresponding page (Editpage.aspx) on the right frame by something like this..
Dim strReDirectToAnotherFrame As String = "<script>window.open(""edit.aspx"" ,""rightframe"");</script>"
Response.Write(strReDirectToAnotherFrame)
POSSIBLE WORK AROUND FOR YOU IF YOU USE FRAMES
When the user closes the window,you can invoke a javascript function and send a query string to another frame,lets say Logo.aspx.
Javascript side on leftpage to send a javascript to server script.
//leftpage.aspx..This function must be invoked when the user close the window.
function clearflag()
{
window.open(""logo.aspx?flag=1"" ,""Logo"");
}
On the server script,
//logo.aspx
Dim flag as string
flag = Request.QueryString("flag")
If (flag = 1) then
//Connect to the database and update the table
End If
Hope this Helps.
With frameset, you can display more than one webform in the same browser window. Each frame is independent of the others.
Disadvantages:
1.Its a mess when you try tuning your frameset for different screen resolution.
2.Each browser has some compactibility issue,but I can be solved easily
3.The web developer must keep track of more webforms.
4.It is difficult to print the entire page.
Advantages:
1.Its really easy to use.
2.You can invoke a server script from a Javascript.
For my application I had three frames.
1.Logo
2.Left frame
3.Right frame
The Logo webform is my secret hide out.I have some hidden server side codes.
The left frame had various buttons like,
1.compose
2.edit profile
3.Signout
4.bla
5.bla bla
when the user clicks these buttons,for example edit profile
I'll executed the server script for calling the corresponding page (Editpage.aspx) on the right frame by something like this..
Dim strReDirectToAnotherFrame As String = "<script>window.open(""edit.aspx"" ,""rightframe"");</script>"
Response.Write(strReDirectToAnotherFrame)
POSSIBLE WORK AROUND FOR YOU IF YOU USE FRAMES
When the user closes the window,you can invoke a javascript function and send a query string to another frame,lets say Logo.aspx.
Javascript side on leftpage to send a javascript to server script.
//leftpage.aspx..This function must be invoked when the user close the window.
function clearflag()
{
window.open(""logo.aspx?flag=1"" ,""Logo"");
}
On the server script,
//logo.aspx
Dim flag as string
flag = Request.QueryString("flag")
If (flag = 1) then
//Connect to the database and update the table
End If
Hope this Helps.
•
•
•
•
Originally Posted by naveenchander
Hi Mr. White Tiger,
The Name of the fish is Dory a Cartoon character in the movie Finding NEMO.
Thanks a lot for your Help Man. That was indeed helpful. If you dont mind, can you explain what did you do with the frameset? So that I will try to tweak up the Code.
Thanks,
NaveenChnader
Save White Tiger
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the ASP.NET Forum
- Previous Thread: Strange problem in sending emails by asp.net
- Next Thread: ASP.net/Stored Proc & Login Verification


Linear Mode