Click to See Complete Forum and Search --> : creating a js object that is globally accessable


pmntdaylt
01-16-2003, 01:33 AM
hey all.. i'm pretty new at asp and i hope this question makes sense..

i'm trying to make a message-board type application with javascript and asp.. what i would like is to have an object of type 'MsgBoard' that has stores an array of messages.. very simple. each time you display the message board page, you can post a new message. it also displays all messages that have been posted,

what i would like is to have one single instance of this object, that is available to anyone that connects to the web page. therefore when anyone posts, everyone can see the message (as the function to read the messages will be accessing the same instance of the messaging board object)

i have no idea how to go about doing this. i've tried things like Application("messageboard") = new MsgBoard(), where my mb object is obviously called MsgBoard.. no such luck. this is my first day with asp/js (i do know java, c/c++ and so on, so i'm not a new programmer thankfully..) so please be gentle if i am making no sense..

regards
mike

vishu_gupt
01-16-2003, 02:54 AM
HI,
I think creating the object for messageboard which will be available to every one is not a good idea. As creating the globally available object will use resources and this will slow down the process.
What you can do is.. store all the messages in a Database Table. On the ASP page where you want to show the messages, just query the table and display all the messages. By this way when ever a new messages will be posted then that page will get it from database and will list out. Using this, you will be in a better control of the things.

:)

vishu_gupt
01-17-2003, 05:26 AM
Thanks Dave,
Its good that you are agree with my approach. Using an Application Variable is not a good choice at all for Message Board applications. As Application variables will be there in the memory till the time you restart your webapplication or change the Global.asa or Manualy stop and start the site. (Though IIS 5 has different ways also). Prefered way is to use database but there is no boundation in not to use Application objects.
:)

drt2928
06-16-2006, 01:28 PM
Hey y'all,

I havent' used JS very much but I am also familiar with other prog lang. The company that I work at will not allow us to store a db on any of the comps or servers and we are trying to make a message board just for our small group of 5 people here at the help desk. The site that we currently have is entirly JS and not made by me, can somebody fill me in on what exactly would need to be done to get a message board that does not get emptied when you close the browser without a db? or send a link to example code for this or some thing, maybe even go so far as to send example code to my email.... anthony.windschitl@oati.net

russell
06-16-2006, 02:50 PM
if they won't let u create database objects on the servers, just do it in MS Access and store the .mdb file on a shared drive. this will work fine for 4 or 5 people using the app.

lmf232s
06-16-2006, 03:42 PM
you could do this w/ a text file also.