PDA

Click to See Complete Forum and Search --> : Popup Problem in Asp.Net!!!!


AjayKumar
Sep 26th, 2005, 11:24 PM
:confused:
Hi,
I am developing as Application in ASP.net and C#.
I want to display popup window to all clients of my application when a new user login or when a new entry goes into my database.Give me some idea about it.
Thanks! :wave:

wild_bill
Sep 26th, 2005, 11:33 PM
Do a search for javascript alert.

mendhak
Sep 27th, 2005, 07:56 AM
:confused:
Hi,
I am developing as Application in ASP.net and C#.
I want to display popup window to all clients of my application when a new user login or when a new entry goes into my database.Give me some idea about it.
Thanks! :wave:
Do you mean that when a new user logs in, people all over the world using your web application should get a popup informing them of this event?

If that's the case, then on every page load, you should perform a check for whether such an event has occurred and depending upon that, throw an alert. Of course, the mechanism for maintaining whether a user has seen the alert or not is going to be slightly tough.

wild_bill
Sep 27th, 2005, 08:16 AM
Might be able to use an application level dataset or datatable that gets updated after the alert onclick event. You would probably want to purge it every so often, as it could get huge.

AjayKumar
Sep 28th, 2005, 12:25 AM
Actually I have an application in which some fault entries for Traffic lights are done online.I want when any user enter any fault then all users who are currently logged in ,should get a popup message that a new fault is registered.I am confused how to do it,whether on client side or server side.
Please suggest any solution with some coding!!

Wokawidget
Sep 28th, 2005, 07:46 AM
When a iser logs in you will need to set some values into a DB...not sure what values as I haven't gone into that much detail with this problem.

Then client side. You create a timer in javascript that say every 10 seconds queries the DB. This would be done using remoting. You would then need more javascript to display a popup window.

Howvere, if all users logged in are constantly checking for new DB things then this will have an impact on the performance of your web app.

Woka

AjayKumar
Sep 29th, 2005, 04:12 AM
Thanks for your suggestion.
Okay,But how do i connect to database using javascript.?
i do not know database connectivity through javascript.

mendhak
Sep 29th, 2005, 05:19 AM
You'll have to connect using a server side language, which in this case should be ASP.NET/VB.NET or ASP.NET/C#

AjayKumar
Sep 29th, 2005, 05:32 AM
"You create a timer in javascript that say every 10 seconds queries the DB. This would be done using remoting."
I have already done connectivity in my application but problem is that how can i display a popup to all online users.

Wokawidget
Sep 29th, 2005, 06:07 AM
well the users clinet will connect to DB, check for data. if data found then display popup.
If 1000 people are on your site then 1000 popups will be seen. and 1000 hits to the DB every 10 seconds will occur.

HUGE HUGE hit on the server and DB.
If the popup shows on 1 client, then it'll show on all, there would be no difference in coding between 2000000 users logging in and say 3.

Do you have code to popup a single window?

Woka

AjayKumar
Sep 29th, 2005, 06:12 AM
Yes i have Javascript code to popup a single window.

public void popup(string fname)
{
string sc,d2;
d2 = "Width=780,Height=350,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0;";
sc = "<script language=JavaScript>";
sc = sc + "window.open('" + fname + "','','" + d2 + "');";
sc = sc + "</script" + ">";

if(!IsClientScriptBlockRegistered("window.open"))
{
RegisterClientScriptBlock("alert", sc);
}

}

In above function i pass name of a particular page and then it get displays.
Problem is that i want to show it to all online users.
Plz write code for that.

please help me.

Wokawidget
Sep 29th, 2005, 06:12 AM
Here;s the javascript to popup a modal window:

function openSelectVisitor(iBookingKey)
{
var sFeatures = ''

sFeatures=''
sFeatures+='top=100,'
sFeatures+='left=200,'
sFeatures+='height=500px,'
sFeatures+='width=400px,'
sFeatures+='scrollbars=no,status=no,toolbar=no'
window.showModalDialog('SelectVisitor.aspx?BookingKey='+iBookingKey,'SelectVisitor',sFeatures)
}

Hope this helps.

Woka

Wokawidget
Sep 29th, 2005, 06:14 AM
OK. You say you can already connect to the DB right.

Do you do this using JScipt or VB.NEt in the codebehind page?

Do you know how to create javascript timer?

Do you know how to do remoting?

Woka

AjayKumar
Sep 29th, 2005, 06:18 AM
Hi,
To simplyfy i want to flash a message for all clients on any event.

AjayKumar
Sep 29th, 2005, 06:21 AM
Hi,
I do not know remoting and timers in javascript.
I have used that popup function in my codebehind(.cs) file.
give me some idea how to do it..

Wokawidget
Sep 29th, 2005, 06:28 AM
This is very complicated in my opinion, well it is if you don't know what you're doing :(

http://www.codeproject.com/aspnet/AlvaroRemoteScripting.asp

have a read of that, and download the demo.
This explains how to do remoting. Not easy.

Woka

AjayKumar
Sep 29th, 2005, 07:25 AM
I do not know how to implement this!

Wokawidget
Sep 29th, 2005, 07:33 AM
Yup, like I said it's very complicated.
Full instructions and demo code are available in that link.

Web UI coding like this is always complicated. Which is why ASP.NET coders get paid more than VB.NET.

Woof

AjayKumar
Sep 29th, 2005, 11:05 PM
Yea,
I have studied that demo code.But it is not solving my problem.
When any client call a remote method then only the current client gets a response from the server.I want this response or some message to all online users.Demo code is explaining concept very much like AJAX(Asyncronous Java Script with XML).
Definitly it is not solving my problem.
Now tell me what i do?

Wokawidget
Sep 30th, 2005, 02:56 AM
ERRRRRR...:confused:
Yes, the client does this call...if you have 10000 users online, then you have 10000 IE clients making the call...and 10000 requests to the DB. Not just one. They will ALL do it.
this is the web. it's asynchronous. You cannot send requests from the web server to IE at random points.

Woka

AjayKumar
Sep 30th, 2005, 05:58 AM
Yea,
I will try this remoting it again today then i will let u know?Is it the only solution to this problem?
thanks

Wokawidget
Sep 30th, 2005, 06:00 AM
I believe so, but my UI knowledge of ASP.NET is limited, or rather my javascript knowledge is very limited.
All cool UI functions in IE are done using javascript, ie timers, menus, etc

Web developement in ASP.NET is more complicated than VB.NET developement, well complicated in another way.

Woka

AjayKumar
Sep 30th, 2005, 06:05 AM
Thanks for your quick response.
But i want when one client makes call other client should know abt this call.
I think it is not possible in this way.It will be very much like chating.
what do u think?

leparduk
Oct 11th, 2005, 06:34 AM
The issue you are raising is one that web developers have struggled with since the inception of the internet. Basically for many reasons (including but not limited to security) the clientside browser cannot be targeted by the code running from the server, (IIS or apache for instance).

Instead client server interaction is request based, with the request being initiated from the client.

So, to summarise your problem, you want one client to post a message, whatever that message is (some data whatever is contains), to the server and for other clients (which remember cannot be targeted by the server) to see that this has occurred. However the only way they can see that this has occurred is for them to request it from the server. But the server can't tell them. Can you see the Chicken and Egg scenario developing?

So in essence Woka has the right idea. Each client must request from the server on a timer whether any events have occurred. This is the part that should be remoting based.

So your solution will take the following format:

A client page will exist that allows a message (data) to be submitted to the server via a form. This will be persisted to a database or similar. The same page will also contain a clientside timer (in either jscript or vbscript - I prefer the former) that runs every 10 or so seconds. This will initiate a remoting call (AJAX or any other library you prefer) which will make a call to another server side page that will return an xml data load containing all messages sent by all users since your last call. You can then display these on your page.

I can provide code for all of this if you need it.

Krenshau
Oct 13th, 2005, 09:37 PM
I see it has been a while since the last post but incase you are still looking there might be another way. If your users login and you track the ip address of the user when they log in you might be able to send the pop up to each user that is logged in.

Don't ask me how. I am still learning myself.

Wokawidget
Oct 14th, 2005, 03:06 AM
not possible.

AjayKumar
Oct 17th, 2005, 01:08 AM
Hi all,
I am very much agree with Woka and Leparduk.

Leparduk,Plz send me code for that as u had explained.
I think timer is the only solution.
Thanks for your responses.

send code soon