Microsoft MVP성태의 닷넷 이야기
Tip/Trick: Enabling Back/Forward-Button Support for ASP.NET AJAX UpdatePanel [링크 복사], [링크+제목 복사]
조회: 9442
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

Tip/Trick: Enabling Back/Forward-Button Support for ASP.NET AJAX UpdatePanel
; http://weblogs.asp.net/scottgu/archive/2006/09/14/Tip_2F00_Trick_3A00_-Enabling-Back_2F00_Forward_2D00_Button-Support-for-ASP.NET-AJAX-UpdatePanel.aspx


Nikhil recently posted a nice blog post that includes a new ASP.NET AJAX-enabled control called "HistoryControl". When added to a page it allows developers to programmatically add logical views into a browser's history list. This enables you to make AJAX enabled sites much more useful, and to follow the standard back/forward navigation paradigm that traditional web apps follow.

For example, the below code could be written by a developer in response to a selection change within a list to to add the previous list selection to the browser's history via Nikhil's "HistoryControl":

private void ContentList_SelectedIndexChanged(object sender, EventArgs e) {
history.AddEntry(contentList.SelectedIndex.ToString()
;
}

Once you add entries into the history control, the back/forward button will be enabled in the browser. Nikhil's history control then exposes a "Navigate" event which fires when you press the forward or back button in the browser, and this event then exposes the identifier entry provided before when the view was added into the browser history. You can then use this to restore the page to whatever state it should be in to match the previous history item and update the page:

private void HistoryControl_Navigate(object sender, HistoryEventArgs e) {

int selectedIndex = 0;

if
(String.IsNullOrEmpty(e.Identifier) == false) {
selectedIndex
= Int32.Parse(e.Identifier);
}

// Update the content being displayed in the page
contentList.SelectedIndex = selectedIndex;

// Mark the update panels as needing an update
mainUpdatePanel.Update();
}

And now your end-users get forward/back button history navigation working with AJAX. You can download the code for Nikhil's history control and start using it here.

Hope this helps,

Scott

Share this post: Email it! | bookmark it! | digg it! | reddit!







[최초 등록일: ]
[최종 수정일: 9/16/2006]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-동일조건변경허락 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.

비밀번호

댓글 작성자
 




1  [2]  3  4  5  6  7  8 
NoWriterDateCnt.TitleFile(s)
173정성태4/12/201111202레지스트리 : 11. BHO를 IE와 탐색기에서 선택적으로 로드하고 싶다면?
172정성태4/1/201110154.NET : 44. ContextBoundObject
171정성태3/30/201110027.NET 4.0 : 1. ASP.NET WF4 / WCF and Async Calls
170정성태3/25/20119811.NET 3.0 : 5. WCF How To’s Index [2]
169정성태3/10/201111204.NET : 43. 열려진 소켓 포트를 소유한 Process ID 구하는 방법 [2]
165정성태10/20/201010809레지스트리 : 10. 탐색기의 특정 폴더에 대해 Webdev.WebServer40.exe 로 호스팅을 시작하는 메뉴 추가
164정성태10/11/201010062.NET : 42. Writing Windows Shell Extension with .NET Framework 4 (C#, VB.NET)
163정성태8/27/20108862.NET : 41. Writing Files from Low-Integrity Processes
162정성태8/24/20109028.NET : 40. Self STS
161정성태5/16/201011954.NET : 39. #SNMP - C# Based Open Source SNMP for .NET and Mono
160정성태5/11/20108998.NET : 38. How to get info from client certificates issued by a CA (C#)
159정성태4/30/20108862.NET : 37. How to write a VS2010 Extension using Statement Lambdas
158정성태12/20/200922815명령행 : 6. 배치 파일에서 현재 디렉터리 알아내는 방법 [1]
157정성태11/12/20099576.NET : 36. Dictionary<,> 개체 직렬화
156정성태11/10/200910727.NET : 35. UDP 패킷의 경유 IP 설정 (Source Routing)
155정성태11/4/20099370.NET : 34. MSDeploy 명령행에 대응되는 C# 코드 예제
154정성태7/13/20098904.NET 3.0 : 4. WCF - 연결 개체 닫기
153정성태6/29/20098278.NET : 33. Creating audio signals in .NET
152정성태1/6/20098901.NET 3.0 : 3. WPF - StatefulUserControlBase.cs
151정성태1/1/200911593.NET : 32. Wake-On-Lan C# 코드 [1]
150정성태12/12/20088251.NET 3.5 : 7. ETW / .NET Framework 3.5
149정성태12/3/20088688Win32 : 4. Using Windows Vista Built-In Double Buffering
148정성태11/25/20087633.NET : 31. ThreadPool.UnsafeQueueNativeOverlapped [1]
147정성태11/21/20086901.NET 3.5 : 6. ProcessGeneratedCode
146정성태10/29/20086801레지스트리 : 9. How to detect what .NET Framework X service pack is installed
145정성태5/6/20087047.NET : 30. XML Serializable Dictionary
1  [2]  3  4  5  6  7  8