PC Review


Reply
Thread Tools Rate Thread

How to avoid down loading an image

 
 
Cal Who
Guest
Posts: n/a
 
      3rd Dec 2009
I want an aspx page to first call a sub that uses confirm() to ask the user
if he want an image displayed.

Something like I show below.

I could have check() simply use window.location to go to the next page if
the user refuses and to return if he says to display the image.

However, even if he refuses the image has already been down loaded which is
should not happen if the user says "no"..

How would you do this?



Thanks





<asp:Content runat="server" ID="Content4" ContentPlaceHolderID="BottomCPH">

<<script type="text/javascript">check()</script>

<img style='border: 0px; width...

</asp:Content>


 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      3rd Dec 2009
This is more of a JavaScript question than an ASP .NET one but, after
confirming that the user wants the image displayed, you can dynamically
create a client-side image object and then load it into an existing image
tag:

var img = New Image();
img.src = "path";
var theImage = document.getElementById("existingImgTagName");
theImage.src = img.src;

-Scott




" Cal Who" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I want an aspx page to first call a sub that uses confirm() to ask the user
>if he want an image displayed.
>
> Something like I show below.
>
> I could have check() simply use window.location to go to the next page if
> the user refuses and to return if he says to display the image.
>
> However, even if he refuses the image has already been down loaded which
> is should not happen if the user says "no"..
>
> How would you do this?
>
>
>
> Thanks
>
>
>
>
>
> <asp:Content runat="server" ID="Content4"
> ContentPlaceHolderID="BottomCPH">
>
> <<script type="text/javascript">check()</script>
>
> <img style='border: 0px; width...
>
> </asp:Content>
>
>



 
Reply With Quote
 
Cal Who
Guest
Posts: n/a
 
      3rd Dec 2009
I haven't been able to use your suggestion because I can't get past some
problems.

I save a cookie with either of the ways shown below and then after a

window.location = "Home/Home.aspx";

takes me to a new window I check with

If Request.Cookies("HideSomeParts").Value Then

Do you see anything wrong with that?

Thanks





// 1 yr from now

var expdate = new Date ();

expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000*365));

document.cookie = 'HideSomeParts=True; expires='+expdate.toGMTString();

OR

Public Sub SaveCookie(ByVal CookieName As String, ByVal CookieValue As
String)

Dim current As HttpContext = HttpContext.Current

Dim tmpCookie As HttpCookie = New HttpCookie(CookieName)

tmpCookie.Value = CookieValue

tmpCookie.Expires = DateTime.Now.AddYears(1)

current.Response.Cookies.Add(tmpCookie)

End Sub







"Scott M." <s-(E-Mail Removed)> wrote in message news:%


(E-Mail Removed)...
> This is more of a JavaScript question than an ASP .NET one but, after
> confirming that the user wants the image displayed, you can dynamically
> create a client-side image object and then load it into an existing image
> tag:
>
> var img = New Image();
> img.src = "path";
> var theImage = document.getElementById("existingImgTagName");
> theImage.src = img.src;
>
> -Scott
>
>
>
>
> " Cal Who" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I want an aspx page to first call a sub that uses confirm() to ask the
>>user if he want an image displayed.
>>
>> Something like I show below.
>>
>> I could have check() simply use window.location to go to the next page if
>> the user refuses and to return if he says to display the image.
>>
>> However, even if he refuses the image has already been down loaded which
>> is should not happen if the user says "no"..
>>
>> How would you do this?
>>
>>
>>
>> Thanks
>>
>>
>>
>>
>>
>> <asp:Content runat="server" ID="Content4"
>> ContentPlaceHolderID="BottomCPH">
>>
>> <<script type="text/javascript">check()</script>
>>
>> <img style='border: 0px; width...
>>
>> </asp:Content>
>>
>>

>
>



 
Reply With Quote
 
Cal Who
Guest
Posts: n/a
 
      3rd Dec 2009
Here is a better descripyion of what happens:
Using JavaScript I set the cookie to true and then do a window.location to a
new aspx window.

In that page I click a checkbox on the master and in the CheckedChanged sub
I save the cookie as False but when the code gets to the Page_PreRender sub
I check it and the value is True.

Why isn't it False there?


Thanks

This is how I check it
>
> If Request.Cookies("HideSomeParts").Value Then


or
If Request.Cookies("HideSomeParts").Value.Contains("True") Then



>
> Do you see anything wrong with that?
>
> Thanks
>
>
>
>
>
> // 1 yr from now
>
> var expdate = new Date ();
>
> expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000*365));
>
> document.cookie = 'HideSomeParts=True; expires='+expdate.toGMTString();
>
> OR
>
> Public Sub SaveCookie(ByVal CookieName As String, ByVal CookieValue As
> String)
>
> Dim current As HttpContext = HttpContext.Current
>
> Dim tmpCookie As HttpCookie = New HttpCookie(CookieName)
>
> tmpCookie.Value = CookieValue
>
> tmpCookie.Expires = DateTime.Now.AddYears(1)
>
> current.Response.Cookies.Add(tmpCookie)
>
> End Sub
>
>
>
>
>
>
>
> "Scott M." <s-(E-Mail Removed)> wrote in message news:%
>
>
> (E-Mail Removed)...
>> This is more of a JavaScript question than an ASP .NET one but, after
>> confirming that the user wants the image displayed, you can dynamically
>> create a client-side image object and then load it into an existing image
>> tag:
>>
>> var img = New Image();
>> img.src = "path";
>> var theImage = document.getElementById("existingImgTagName");
>> theImage.src = img.src;
>>
>> -Scott
>>
>>
>>
>>
>> " Cal Who" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>I want an aspx page to first call a sub that uses confirm() to ask the
>>>user if he want an image displayed.
>>>
>>> Something like I show below.
>>>
>>> I could have check() simply use window.location to go to the next page
>>> if the user refuses and to return if he says to display the image.
>>>
>>> However, even if he refuses the image has already been down loaded
>>> which is should not happen if the user says "no"..
>>>
>>> How would you do this?
>>>
>>>
>>>
>>> Thanks
>>>
>>>
>>>
>>>
>>>
>>> <asp:Content runat="server" ID="Content4"
>>> ContentPlaceHolderID="BottomCPH">
>>>
>>> <<script type="text/javascript">check()</script>
>>>
>>> <img style='border: 0px; width...
>>>
>>> </asp:Content>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Gregory A. Beamer
Guest
Posts: n/a
 
      3rd Dec 2009
" Cal Who" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> Here is a better descripyion of what happens:
> Using JavaScript I set the cookie to true and then do a
> window.location to a new aspx window.
>
> In that page I click a checkbox on the master and in the
> CheckedChanged sub I save the cookie as False but when the code gets
> to the Page_PreRender sub I check it and the value is True.
>
> Why isn't it False there?


Here is how it works

1. user hits page
2. User says no
3. Cookie created
4. Look for cookie (not sent yet)
5. Image shown
6. Cookie and page information sent to browser

AND

7. Refresh page
8. Cookie found
9. Image not shown

Whether the checkbox is set or not is not the issue.

This is really an architectural problem more than anything. Here is how
I would set up the code.

In page load
1. Check for cookie
2. If not exist, send user to form (do you want images)
3. If exists, check if user wants images
4. If wants images show images

In button click
1. Check checkbox
2. If yes, show image and set cookie to true
3. If not, don't show and set cookie to false

This covers both the a) here and now and b) future when the user
returns.

Peace and Grace,


--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Reply With Quote
 
Cal Who
Guest
Posts: n/a
 
      3rd Dec 2009

"Gregory A. Beamer" <(E-Mail Removed)> wrote in message
news:Xns9CD696662987Cgbworld@207.46.248.16...
>" Cal Who" <(E-Mail Removed)> wrote in
> news:(E-Mail Removed):
>
>> Here is a better descripyion of what happens:
>> Using JavaScript I set the cookie to true and then do a
>> window.location to a new aspx window.
>>
>> In that page I click a checkbox on the master and in the
>> CheckedChanged sub I save the cookie as False but when the code gets
>> to the Page_PreRender sub I check it and the value is True.
>>
>> Why isn't it False there?

>
> Here is how it works
>
> 1. user hits page
> 2. User says no
> 3. Cookie created
> 4. Look for cookie (not sent yet)
> 5. Image shown
> 6. Cookie and page information sent to browser
>
> AND
>
> 7. Refresh page
> 8. Cookie found
> 9. Image not shown
>
> Whether the checkbox is set or not is not the issue.
>
> This is really an architectural problem more than anything. Here is how
> I would set up the code.
>
> In page load
> 1. Check for cookie
> 2. If not exist, send user to form (do you want images)
> 3. If exists, check if user wants images
> 4. If wants images show images
>
> In button click
> 1. Check checkbox
> 2. If yes, show image and set cookie to true
> 3. If not, don't show and set cookie to false
>
> This covers both the a) here and now and b) future when the user
> returns.
>
> Peace and Grace,
>
>
> --
> Gregory A. Beamer (MVP)
>

Thanks, I'll see how that works.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
avoid loading an empty form =?Utf-8?B?c2VndXJhcmw=?= Microsoft Access External Data 3 21st Jul 2006 01:44 PM
avoid loading roaming profiles pete Microsoft Windows 2000 Active Directory 1 24th Nov 2003 06:48 PM
avoid loading roaming profiles pete Microsoft Windows 2000 Active Directory 0 21st Nov 2003 03:44 PM
avoid loading roaming profiles pete Microsoft Windows 2000 Active Directory 0 21st Nov 2003 03:44 PM
Binding a SQL Image Column to an Image Control - Can I Avoid Saving The ByteStream/FileStream To Disk ? Ben Willett Microsoft ADO .NET 1 29th Sep 2003 08:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:35 PM.