?
Solved

Need to force a page reload in ASP.NET OR solve a flash problem

Posted on 2006-04-04
5
Medium Priority
?
696 Views
Last Modified: 2008-02-01
Hi.

I am using Swishmax and have created flash movies for products on my site.

My site is bilingual, so that on each page I have an English and a French version of the flash (2 different movies on the same page). I have put each of the movies in a different <asp:panel>, and I am setting their visibility property to true or false depending if the cookie identifies the user as an english or a french visitor.

The code works fine whenever a visitor comes in from any language.

Now I also have a "Change language" button on my webpage, which changes the person's language preference in their cookies.

Now if I go back to the page with the flash movies (after I changed the language at least one time), it will always show the flash IN THE PERSON'S PREVIOUS LANGUAGE. It just seems to totally ignore the code, and seems to think the flash it has already loaded is just fine.

So I have the wrong language on the screen. But if I push reload on the browser, the page language changes and the page loads the correct flash movie.

Here's my code, where the <asp:panels> are named "air" and "airf":


Sub Page_Load(Source as Object, E as EventArgs)
      
   If Not Request.Cookies ("userprofile") Is Nothing then
          Whichlang = Request.Cookies ("userprofile")("langpref")
   end if

   air.Visible = False
   airf.Visible = False
       
   If Whichlang = "english" then
          air.Visible = True
   else
          airf.Visible = True
   end if

End Sub


Help ! I need to release the site ASAP!


Thanks,

Peter
0
Comment
Question by:pbissegger
  • 2
  • 2
5 Comments
 

Author Comment

by:pbissegger
ID: 16377915
OK, did a bit of additional debugging and have some more info:

1. When I get the problem, the entire page (not just the flash movie) is in the wrong language.

2. The problem occurs only when I call the page from another flash movie (not from HTML code on another page). Again though the flash movie just calls a page products.aspx, but it seems like it's calling a CACHED or previous version of that page.

Interesting .....

Thanks,

Peter
0
 
LVL 37

Assisted Solution

by:samtran0331
samtran0331 earned 400 total points
ID: 16377983
one thing you can try is to set the products.aspx page to never cache...
put this in the <head>..

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 16378145
cls u post the code where u store the cookie and also the code for the "Change Language" button .. remember the code for the page load always gets fired first .. so it seems that ur change language code just contains code to change the cookie value .. But the page load is run first and so changing the cookie after that would not affect ur code written in page load ..  ur code should be something like this ..

Sub Page_Load(Source as Object, E as EventArgs)
  if not page.ispostback then
      If Not Request.Cookies ("userprofile") Is Nothing then
          Whichlang = Request.Cookies ("userprofile")("langpref")
      end if
      ChangePanel(Whichlang)
   end if
End Sub

Sub ChangePanel(byval Whichlang as string)

   air.Visible = False
   airf.Visible = False
       
   If Whichlang = "english" then
          air.Visible = True
   else
          airf.Visible = True
   end if

End Sub

Within the ChangeLanguage button
change the value of the cookie and then call ChangePanel passing the new language .. no need to read the cookie again...

Rejo
0
 
LVL 26

Accepted Solution

by:
Rejojohny earned 1600 total points
ID: 16378157
as for not caching the page just add this line in page load
Response.Cache.SetCacheability(HttpCacheability.NoCache)

Sub Page_Load(Source as Object, E as EventArgs)
    Response.Cache.SetCacheability(HttpCacheability.NoCache)
    if not page.ispostback then
      If Not Request.Cookies ("userprofile") Is Nothing then
          Whichlang = Request.Cookies ("userprofile")("langpref")
      end if
      ChangePanel(Whichlang)
   end if
End Sub
0
 

Author Comment

by:pbissegger
ID: 16378320
Both ideas sounded really great but unfortunately did not solve my problem. I tried them each on their own, and together, from both the calling page and the destination page.

As requested, please find below my code for the change language button as well as the cookie storage. However, I have checked the cookies and they are working fine. In other words, if I expect an english page the cookie will say english, but the page will display french.

Now, the change language function is in a file called top.ascx, which provides a common top of the page for each of the pages on my site.

Sub Changelanguage(sender As Object, e As CommandEventArgs)

if e.CommandName = "english" then
     aCookie.Values("langpref") = "english"
else
     aCookie.Values("langpref") = "french"
end if
            
aCookie.Expires = DateTime.Now.AddDays(365)
aCookie.Domain = "www.mydomian.ca"
Response.Cookies.Add (aCookie)      

Thisstring = request.servervariables("URL")
Response.Redirect(right(thisstring,len(thisstring)-1))

End Sub

and the HTML is

        <table>
            <tbody>
                <tr>
                    <td>
                        <asp:ImageButton id="btnEnglish" ImageURL="images/English.jpg" height="25" width="103" border="0" onCommand="Changelanguage" CommandName="english" Runat="server" /></td>
                    <td>
                        <asp:ImageButton id="btnFrench" ImageURL="images/French.jpg" height="25" width="108" border="0" onCommand="Changelanguage" CommandName="french" Runat="server" /></td>
                </tr>
            </tbody>
        </table>



Thanks for your help - we'll find the problem yet !

Peter
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question