Microsoft MVP성태의 닷넷 이야기
Tip/Trick: Enabling Back/Forward-Button Support for ASP.NET AJAX UpdatePanel [링크 복사], [링크+제목 복사]
조회: 9436
글쓴 사람
정성태 (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)
120정성태9/14/20074712Vista : 7. Gadget Samples for Windows Sidebar
119정성태8/23/20074966.NET 3.5 : 3. WCF 서비스에서 HTTP 헤더 설정
118정성태6/20/20075487.NET 3.5 : 2. LINQ - 페이징 구현
117정성태6/20/20075139.NET : 23. Silverlight 응용 프로그램 제작
116정성태6/19/20075464.NET : 22. Bluetooth on Managed code [2]
115정성태6/17/20074832레지스트리 : 4. .NET Framework 및 Visual Studio 관련 레지스트리 키
114정성태6/9/20075196레지스트리 : 3. DWM enable/disable
113정성태6/9/20074660Vista : 6. 웹 사이트 추가/삭제 예제 코드
112정성태6/7/20074628Vista : 5. Transacted NTFS 코드 예제들
111정성태6/6/20074908.NET 3.5 : 1. LINQ 를 이용하여 DB 데이터를 XML 로 변환
110정성태6/2/20074814레지스트리 : 2. Aero Glass 효과를 느리게 보여주는 설정
109정성태5/19/200710341공통 코딩 규약 : 4. 닷넷 직렬화 방법 - 이진 직렬화(Binary Serialization) 사용 패턴
108정성태5/19/20074781공통 코딩 규약 : 3. 탭 문자 설정 [1]
107정성태5/11/20074672명령행 : 5. 비스타 - Auditing 관련 옵션 제어
106정성태5/11/20075656.NET 3.0 : 2. WPF - InvokeRequired 대신 CheckAccess 호출
105정성태5/9/20074445명령행 : 4. [PS] 같은 이름을 가진 프로세스 중에서 제일 먼저 띄운 인스턴스를 제외하고 모두 종료
104정성태5/3/20074429명령행 : 3. [롱혼] ServerManagerCmd.exe
103정성태4/18/20074478웹폼 코딩 규약 : 1. 서버측 웹폼 컨트롤 - 클라이언트 측 이벤트를 노출시키는 방법
102정성태4/18/20075878COM : 3. ActiveScript의 문법 오류 검사 [3]
101정성태4/18/20075086레지스트리 : 1. 비스타 - IIS 서비스 설치 여부
100정성태3/29/20074531명령행 : 2. AppPool 재시작
99정성태3/22/20074707명령행 : 1. 닷넷 웹 사이트 소스를 공유 폴더에 위치한 경우 설정
98정성태3/7/20075176.NET : 21. 저장 프로시저(SP)에 관한 스키마 정보 알아내기
97정성태3/7/20074533.NET 3.0 : 1. Boilerplate code for custom Encoder Binding Elements
96정성태3/7/20075262Vista : 4. 마스터 볼륨을 조정하는 방법
95정성태2/23/20074972.NET : 20. .Net Zip Library/Utility updates and fixes
1  2  3  [4]  5  6  7  8