ASPX uses cookie values to stop timers in Silverlight

Source: Internet
Author: User
Tags silverlight

I. Silverlight and Silverlight can use delegates (delegate) to refresh Frame.refresh ()

1. Defining a delegate Snap Close event button in a subclass

1          Public Delegate voidOncloseclick (Objectsender, RoutedEventArgs e);2          PublicOncloseclick OnClose;3         Private voidCancelbutton_click (Objectsender, RoutedEventArgs e)4         {5             if(OnClose! =NULL)6             {7 OnClose (sender, E);8             }9              This. Visibility =visibility.collapsed;Ten}

2. Invoke the Frame.refresh () method using a delegate in the page where the frame is located

list<button> Listbutton = showopenpanelconfig (TB);                 New Child_yjcbs ();                 = EasySL.Controls.Window.ShowOpPanel (" one key out of table "this. Floatepanel, Txtmsginfo) ;                 + = (s, e) = = {Contentframe.refresh ();                }; + = (s, e)                    = = visibility.collapsed; Contentframe.refresh ();                };
View Code

Second, use the cookie in ASPX to control the timer in SL
1. Define a timer on the page where frame is located

1  Private voidTimeinitdata ()2         {3             if(Mydispatchertimer! =NULL)4 mydispatchertimer.stop ();5             //Create a timer6Mydispatchertimer =NewSystem.Windows.Threading.DispatcherTimer ();7             //Create interval time8Mydispatchertimer.interval =NewTimeSpan (0,0,0,5);9             //functions to be executed after the arrival interval has been createdTenMydispatchertimer.tick + = (ss, ee) = = One             { A                  This. Contentframe.refresh (); -string[] cookies = HtmlPage.Document.Cookies.Split (';'); -                 foreach(String Cookieinchcookies) the                 { -string[] KeyValues = cookie. Split ('='); -                     { -                         if(keyvalues[0]. Trim () = ="Fircookiekey") +                         { - mydispatchertimer.stop (); +                         } A                     } at                 } -  -             }; - Mydispatchertimer.start (); -}

2. Create a cookie in the ASPX page and set the expiration time of the cookie

1  if(issuccess)2             {3 Response.Cookies.Clear ();4HttpCookie MyCookie =NewHttpCookie ("Fircookiekey");5Mycookie.value ="Newcookievalue";6Mycookie.expires =datetime.now.add (Timespan.fromminutes (0.2));7 HttpContext.Current.Response.Cookies.Add (MyCookie);8Server.Transfer ("previewreport.aspx");9                 //Page.Response.Write ("<script language=javascript>alert (\" Insert Success!\ ");</script>");Ten}

Note: The cookie expiration time set above is 12 seconds, and SL is loaded once in 5 seconds,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.