473,569 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AJAX vs. Cookies - Am I just silly?

Hi.

I have an ASP.NET application written in C#. In part of my
application, I want to use JavaScript OnClick event function to
update a textbox with a string generated asynchronously on the server.
I have pretty much figured out two ways to this. One way involves
AJAX. The other way involves using cookies.

I think AJAX is awesome, but what if the user's browser blocks ActiveX
controls? On the other hand what if the browser blocks cookies? Should
I implement both ways of doing the task, and go the cookies route if
ActiveX controls are blocked?

Any thoughts are welcomed.

Thanks for the bandwidth.

-Doug

Feb 17 '07 #1
9 4838
On Feb 17, 12:38 pm, "dougloj" <doug...@msn.co mwrote:
Hi.

I have an ASP.NET application written in C#. In part of my
application, I want to use JavaScript OnClick event function to
update a textbox with a string generated asynchronously on the server.
I have pretty much figured out two ways to this. One way involves
AJAX. The other way involves using cookies.

I think AJAX is awesome, but what if the user's browser blocks ActiveX
controls? On the other hand what if the browser blocks cookies? Should
I implement both ways of doing the task, and go the cookies route if
ActiveX controls are blocked?

Any thoughts are welcomed.

I'm curious how cookies can replace an Ajax request. If you can send
the string in a cookie then you know what should be in the textbox
when you serve the page. In that case you don't need either Ajax or
cookies. Just put the string in a JavaScript variable when you
dynamically generate the page.

So what exactly are you trying to do?

Peter

Feb 17 '07 #2
I'm curious how cookies can replace an Ajax request. If you can send
the string in a cookie then you know what should be in the textbox
when you serve the page. In that case you don't need either Ajax or
cookies. Just put the string in a JavaScript variable when you
dynamically generate the page.

So what exactly are you trying to do?

Peter
Peter,

My ASP.NET application submits info to a database. Another application
gets the info from the database and eventually replies by updating the
database. The ASP.NET application the reply and shows the reply to the
user. This all happens asynchronously.

While the users is wainting, a small anamation is displayed. When the
reply is ready, the animation is hidden and the reply is displayed.
The animation and reply are each actually displayed on seperate .aspx
pages that are viewed in the application by an iframe window.

I want the user to be able to print the reply when it arrives.
Unfortunately, my print process won't pick up the contents of the
iframe which contains the reply.

So, when the user clicks the Print button, I want to grab the reply
text, assign it to a lable in an area on the page which will be picked
up by the print process, and print it along with other info on the
page.

As I see it, I have 2 ways of "grabbing" the string. One way is to
write the string to a cookie on the server when it's ready. My
JavaScript code can check for the cookie when the Print button is
clicked. The 2nd way is to write the string to a session variable on
the server when the string is ready, and use AJAX to get the string
when Print is clicked.

Any ideas of a better way, or input on the AJAX vs. Cookie matter are
welcomed.

Thanks.

Doug

Feb 18 '07 #3
On Feb 17, 7:29 pm, "dougloj" <doug...@msn.co mwrote:
While the users is wainting, a small anamation is displayed. When the
reply is ready, the animation is hidden and the reply is displayed.
The animation and reply are each actually displayed on seperate .aspx
pages that are viewed in the application by an iframe window.

I want the user to be able to print the reply when it arrives.
Unfortunately, my print process won't pick up the contents of the
iframe which contains the reply.
Why not pick out the response from the iframe?

Or set the focus to the iframe and then it'll print instead.

Kev

Feb 18 '07 #4
On Feb 17, 7:34 pm, "Kevin Darling" <kdarl...@basit .comwrote:
>
Why not pick out the response from the iframe?

Or set the focus to the iframe and then it'll print instead.

Kev
Kev,

I tried using the innerHTML and innerText of the iframe to get the
response text, but they are empty. Do you know how to get the text
content from an iframe in JavaScript?

As far as the printing goes, I want to print the response text along
with other info on the page. The other info is in a div. Right know, I
write the response text to a cookie on the server when it's ready. My
onClick function for the Print button checks the cookie. If the cookie
exists, I grab the response text, put it in the innerText of a span
within my div, and print the innerText of the whole div.

The JavaScript code for the printing is as follows:

// summaryDiv contains everything that is to be printed,
// including the response span

var summaryDiv = document.getEle mentById("summa ryDiv");

var WinPrint = window.open('', '','letf=0,top= 0,width=1,
height=1,toolba r=0,scrollbars= 0,status=0');

WinPrint.docume nt.write(summar yDiv.innerHTML) ;
WinPrint.docume nt.close();
WinPrint.focus( );
WinPrint.print( );
WinPrint.close( );

If you or anybody has any ideas about a better way to the print, how
to get the text content of an iframe, or any thoughts on the AJAX vs.
Cookies issue, I'd love to hear from you.

Thanks.

Doug

Feb 18 '07 #5
dougloj wrote:
>
I think AJAX is awesome, but what if the user's browser blocks ActiveX
controls? On the other hand what if the browser blocks cookies? Should
I implement both ways of doing the task, and go the cookies route if
ActiveX controls are blocked?
AJAX has nothing whatever to do with ActiveX. So - to answer your
question about it - it is irrelevant if a user blocks ActiveX.
Similarly, AJAX has nothing whatever to do with cookies and the answer
to your second question is also that it is irrelevant.

I have no idea what you mean by "both ways" since AJAX requires
*neither* ActiveX *nor* cookies!
Feb 19 '07 #6
Hi,

The Magpie wrote:
dougloj wrote:
>I think AJAX is awesome, but what if the user's browser blocks ActiveX
controls? On the other hand what if the browser blocks cookies? Should
I implement both ways of doing the task, and go the cookies route if
ActiveX controls are blocked?
AJAX has nothing whatever to do with ActiveX. So - to answer your
question about it - it is irrelevant if a user blocks ActiveX.
Similarly, AJAX has nothing whatever to do with cookies and the answer
to your second question is also that it is irrelevant.

I have no idea what you mean by "both ways" since AJAX requires
*neither* ActiveX *nor* cookies!
To be fair, XmlHttpRequest in IE6 and older is created using an ActiveX
component.

However, I believe that even if the user blocks ActiveX, the blocking
doesn't affect invisible ActiveX component. I might be wrong though.

Greetings,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Feb 19 '07 #7
Laurent Bugnion [MVP] said the following on 2/19/2007 4:20 PM:
Hi,

The Magpie wrote:
>dougloj wrote:
>>I think AJAX is awesome, but what if the user's browser blocks ActiveX
controls? On the other hand what if the browser blocks cookies? Should
I implement both ways of doing the task, and go the cookies route if
ActiveX controls are blocked?
AJAX has nothing whatever to do with ActiveX. So - to answer your
question about it - it is irrelevant if a user blocks ActiveX.
Similarly, AJAX has nothing whatever to do with cookies and the answer
to your second question is also that it is irrelevant.

I have no idea what you mean by "both ways" since AJAX requires
*neither* ActiveX *nor* cookies!

To be fair, XmlHttpRequest in IE6 and older is created using an ActiveX
component.

However, I believe that even if the user blocks ActiveX, the blocking
doesn't affect invisible ActiveX component. I might be wrong though.
If the user blocks ActiveX, then ActiveX is blocked. Meaning, if ActiveX
is blocked then "AJAX" won't work in IE6 and prior IE browsers.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 19 '07 #8
Laurent Bugnion [MVP] wrote:
The Magpie wrote:
<snip>
>AJAX has nothing whatever to do with ActiveX. ...
<snip>
To be fair, XmlHttpRequest in IE6 and older is created
using an ActiveX component.

However, I believe that even if the user blocks ActiveX,
the blocking doesn't affect invisible ActiveX component.
I might be wrong though.
I don't know what you mean by "invisible ActiveX component". With the
Internet security setting for "Script controls marked safe for scripting"
set to disabled (and/or, I seem to recall, "Run ActiveX controls and
plug-ins" disabled) the ActiveX XML HTTP request component cannot be
instantiated in IE 6.

Microsoft has suffered in the past from more controls being "marked safe
for scripting" than actually were safe. The XML HTTP request object is
not among that group, but the safe option (for the user) is still to
disable that stetting for Internet use. And my money would be on a
security update for IE 6 disabling it by default as soon as Microsoft
think that the take-up of IE 7 is height enough for the loss of XML HTTP
requests in IE 6 not to seem important to .NET customers.

Richard.

Feb 19 '07 #9
Hi Randy,

Randy Webb wrote:
Laurent Bugnion [MVP] said the following on 2/19/2007 4:20 PM:
>>
However, I believe that even if the user blocks ActiveX, the blocking
doesn't affect invisible ActiveX component. I might be wrong though.

If the user blocks ActiveX, then ActiveX is blocked. Meaning, if ActiveX
is blocked then "AJAX" won't work in IE6 and prior IE browsers.
Thanks for the correction. I got to try that, I must have an old IE6
running somewhere...

Greetings,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Feb 19 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
7846
by: Agoston Bejo | last post by:
Hi, I searched around everywhere on the net, but could not find a simple example of detecting if cookies are enabled - on server side, and without moving from one page to another. This should be a very basic functionality, so I am reluctant to believe that there's no way to simply test it in a server-side script. Anyone? Thx, Agoston
8
2326
by: CDARS | last post by:
Hi all, I have a confusing question on ASP.NET cookies usage: 1> Response.Cookies("test").value = Now 2> Response.Write(Request.Cookies("test").value) 3> 4> Response.write("<hr>") 5> 6> Response.Cookies("test").value = Now.AddDays(10)
4
7454
by: evgenyg | last post by:
Hello ! We have the following situation - when Ajax request is sent what's being returned by the server is usually an XML (which is used for DOM updates) but sometimes it's HTML which is a whole new page that should replace an existing one. I.e when we issue an Ajax request we don't know what will be returned and analyze the response to act...
5
13774
by: Jono | last post by:
Hi Everyone, Most tutorials I've seen address cookies from the server's perspective, assuming that the client (usually a browser like Internet Explorer) will manage the persistence. I am faced with writing a C#.NET client that uses a web reference to a SOAP web service, and I need to persist the cookies myself, or so it seems. The cookies...
5
3395
by: Ruso | last post by:
I am using ASP to make an application. What I want right now - is to make the self updating list of the users online - based on thier cookies. In my opinion all seems to be writen well with it's logic, but computer thinks otherwise. I use application("loged") to store the cookies of all users. Here is a code: main.asp
4
6162
by: Mr. SweatyFinger | last post by:
OK I don't understand ajax, but my page makes a quick ajax call to another page and returns the results. that works ok. That other page is supposed to set a cookie. That doesn't seem to work. Is that because ajax doesn't send all the headers and cookies, or am i being a big dumb jerk?
2
1601
by: rb | last post by:
Hi, This is a very silly (and newbie) question but... I started a new site; added on default.aspx a text box and a button. On Button Click, I do this: HttpCookie cookie; cookie = new HttpCookie( "test", TextBox1.Text ); cookie.Expires.AddDays( 365 ); cookie.Domain = "localhost";
5
22566
by: pbd22 | last post by:
Hi. I am having a hard time figuring this one out... I have a sign in page. in my sign in logic, the successful login uses forms authentication and assigns an HttpCookie for the site-wide "user id" (ie. "Welcome BillG ! "). when the user clicks on "signout" from any given page, an XMLHttp call queries a server script (VB.NET) which
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.