Microsoft MVP성태의 닷넷 이야기
Tip/Trick: Enabling Back/Forward-Button Support for ASP.NET AJAX UpdatePanel [링크 복사], [링크+제목 복사]
조회: 9441
글쓴 사람
정성태 (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)
95정성태2/23/20074976.NET : 20. .Net Zip Library/Utility updates and fixes
94정성태2/23/20074768COM : 2. VC++ - OneNote Addin 제작
93정성태2/3/20075597공통 코딩 규약 : 2. 프로퍼티와 공용 필드에 대한 선택 [1]
92정성태2/1/20074752공통 코딩 규약 : 1. HMACSHA512 / HMACSHA384 클래스 사용시 주의사항
91정성태1/27/20075034.NET : 19. HTML InnerText 구하기
90정성태1/27/20076685Vista : 3. 현재 사용자가 관리자 그룹에 속해 있는지 결정하는 코드
89정성태1/24/20074206.NET : 18. ASP.NET - AspNetHostingPermissionLevel 알아내기
88정성태1/22/20074478.NET : 17. 지역화된 폰트명 구하기
87정성태1/21/20075823.NET : 16. 클립보드 - HTML 텍스트 복사/붙여넣기
86정성태1/21/20074730.NET : 15. BinaryFormatter 에서의 진행 상태바 구현
85정성태1/20/20075667COM : 1. IE 7의 다중 탭을 이용한 네비게이션 [1]
84정성태1/19/20074573.NET : 14. 웹 서비스를 이용한 머신 간의 클립보드 공유
83정성태1/12/20074504.NET : 13. SafeHandles 를 적용한 GetProcAddress 래퍼
82정성태1/12/20074206.NET : 12. Cardspace 를 위한 ASP.NET 서버 컨트롤파일 다운로드1
81정성태1/12/20074534.NET : 11. 파일 확장자에 따른 아이콘 그려주는 HttpHandler [2]파일 다운로드1
80정성태1/10/20075256SQL : 1. SQL 2005 - 대소문자 구분없이 검색하도록 구현 [1]
79정성태1/10/20074155.NET : 10. Config 설정을 .NET Class 로 매핑
78정성태1/3/20074613.NET : 9. 텍스트 꾸미는 코드
77정성태12/13/20064807.NET : 8. C# - VARIANT 관련 마샬링 코드
76정성태12/6/20065380.NET : 7. 휴대 장치 열람하는 코드
75정성태12/6/20064486.NET : 6. 웹 서비스 메서드에 대해 완료 제한 시간 설정하는 방법
74정성태11/6/20064548.NET : 5. How to Decrypt an ASP.NET Encrypted Data
73정성태11/2/20065426.NET : 4. 콘솔 프로그램 실행시간 측정
72정성태11/1/20064694.NET : 3. System Monitoring 예제
70정성태11/1/20064242.NET : 2. System.Net.NetworkInformation.Ping 클래스 사용 예제
69정성태10/27/20064546.NET : 1. Typed DataSet 에서의 ExcludeSchema 사용
1  2  3  4  [5]  6  7  8