Microsoft MVP성태의 닷넷 이야기
Tip/Trick: Enabling Back/Forward-Button Support for ASP.NET AJAX UpdatePanel [링크 복사], [링크+제목 복사]
조회: 9431
글쓴 사람
정성태 (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)
145정성태5/6/20087015.NET : 30. XML Serializable Dictionary
144정성태3/28/20087639.NET : 29. WPF 응용 프로그램 - 웹캠으로 입력되는 스트림을 WMV 로 출력
143정성태3/28/20087932레지스트리 : 8. VHD 파일을 하드 디스크로 인식
142정성태3/26/20087264레지스트리 : 7. 아웃룩 2007의 제한된 첨부 파일을 허용하도록 설정
141정성태3/25/20087163레지스트리 : 6. 웹 브라우저(IE 8) 컨트롤 렌더링 모드 지정
140정성태2/23/20086569.NET : 28. 프로세스를 실행시켜주는 간단한 NT 서비스 제작 [1]
139정성태2/22/20085780.NET : 27. P/Invoke 를 이용한 메시지 서명 및 확인
138정성태2/21/20087301SMTP Commands
137정성태2/19/20085954.NET 3.5 : 5. LINQ to XML : Creating XML from another XML
136정성태2/1/20088083Win32 : 3. 사용자 개입없이 인증서 설치하는 코드 [2]
135정성태1/30/20085654COM : 5. Starting a Hyper-V Virtual Machine [3]
134정성태1/28/20085825Win32 : 2. How to generate key pairs, encrypt and decrypt data with CryptoAPI
133정성태1/16/20085893유틸리티 : 1. Writing Debugger extension program in C#
132정성태1/15/20086109VS.NET Addin - DB 연결 개체 추가
131정성태1/11/20085996기타 : 1. Maze Generator in C#
130정성태1/8/20086110VS.NET Addin - 프로젝트 닫기
129정성태1/2/20085849웹폼 코딩 규약 : 2. 서버측 ViewState 저장소
128정성태12/31/20075340레지스트리 : 5. List of registry keys affecting IIS7 behavior
127정성태12/21/20076057.NET : 26. CreateProcessWithLogonW / CreateProcessAsUser API 사용
126정성태12/20/20075088Win32 : 1. SLDF_RUNAS_USER
125정성태12/14/20075413.NET : 25. InfoPath 사용자 컨트롤
124정성태11/25/20075107SQL : 2. SQL Server 2008 에서 소개하는 spatial 데이터 타입
123정성태11/20/200711788.NET : 24. C# WebCam 사용자 컨트롤
122정성태11/17/20076200COM : 4. 외부 SMTP 를 지정하여 메일 보내기
121정성태9/14/20074880.NET 3.5 : 4. Entity Framework 관련 링크 모음
120정성태9/14/20074708Vista : 7. Gadget Samples for Windows Sidebar
1  2  [3]  4  5  6  7  8