Microsoft MVP성태의 닷넷 이야기
Tip/Trick: Enabling Back/Forward-Button Support for ASP.NET AJAX UpdatePanel [링크 복사], [링크+제목 복사]
조회: 9433
글쓴 사람
정성태 (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)
197정성태7/30/20211480.NET : 63. Spectre.Console
196정성태10/28/20193153장치 관리자처럼 각 장치들에 할당된 리소스(예: Memory Range) 상태를 코드로 알아내는 방법
195정성태4/25/20192962Extracting Text from an Image Using Tesseract in C#
194정성태4/25/20192715Parse the Command Line with System.CommandLine
193정성태8/2/20175602.NET : 62. github - C# to JavaScript, WPF to JavaScript and Samples
192정성태6/29/20165145.NET : 61. TreeLib: Balanced Binary Trees ? Rank Augmented, for .NET
191정성태10/13/20156348.NET : 60. MICROSOFT TRANSLATOR HUB
190정성태6/20/20157061Win32 : 6. UMDH Visualizer - Memory profile viewer
189정성태1/19/20148675.NET : 59. QR 코드를 ASP.NET과 WPF에서 사용하는 방법
188정성태1/15/20148873.NET : 58. 윈도우폰 7 - 안면인식, Cartooning...
187정성태1/14/20148810.NET : 57. BCL에서 제공되는 컬렉션에 만족하지 못한다면? [1]
186정성태6/26/20138756.NET : 56. The managed way to retrieve text under the cursor (mouse pointer)
185정성태9/27/20129627.NET : 55. Face Detection with Emgu CV in C# and WPF
184정성태9/23/20128463.NET : 54. What was that sound Visual Studio? Audio Editor Beta For VS 2012 (plus free sounds library too!)
183정성태4/19/201210224.NET : 53. Virtual Router 소스 코드 및 실행 파일 (C#)
182정성태4/16/201210803.NET : 52. SharpDX [1]
181정성태3/3/201214122.NET : 51. .NET에서 DirectX를 이용하여 스크린 캡쳐를 빠르게 하는 방법 [3]
180정성태3/3/20129301.NET : 50. Restart Manager 를 이용하여 .NET 에서 잠긴 파일을 소유하고 있는 프로세스 찾는 방법
179정성태1/14/20128624.NET : 49. WebAPI Developer Preview 6: Self Hosted Mode Example
178정성태10/31/201110702.NET : 48. app.config의 supportedRuntime 예시
177정성태10/15/20119602.NET : 47. Irony - Language Implementation Kit
176정성태7/22/20119527.NET : 46. Manual Validation with Data Annotations
175정성태5/18/201111270Win32 : 5. UuidCreateSequential
174정성태5/4/20119744.NET : 45. NTrace v2 now available (think Managed VS2010/.Net 4 Event Tracing for Windows)
173정성태4/12/201111170레지스트리 : 11. BHO를 IE와 탐색기에서 선택적으로 로드하고 싶다면?
[1]  2  3  4  5  6  7  8