Click here to Skip to main content
15,891,431 members
Articles / Web Development / ASP.NET
Article

Smart Navigation Fix Up Module

Rate me:
Please Sign up or sign in to vote.
1.43/5 (5 votes)
27 Jan 20061 min read 33.6K   235   15   8
Smart Navigation Fix Up Control solves the issues that ASP.Net developers face while using SmartNavigation option of the .Net Framework. Its a custom control and is easy to use.

Introduction

Its an updated version of the control provided at this link "http://www.codeproject.com/aspnet/lili.asp" by "Ibrahim ULUDAG". I really appreciate his work.

SmartNavigationFixupModule is an  easy to use custom control.

When we set SmartNavigation = true for a web page we (in fact i have faced) face following two major issues:

  1. Popup window that  i open in my form, is minimized.
  2. When I try to setfocus to control programatically it enters into an infinite loop.

The control provided in the above link worked only on submit buttons, I updated that to capture the scroll event of the window.

How this control works?

The control actually stores the scroll position of the web page before postback, and brings the user back to that position when page is reloaded after postback.

The control creates two hidden variables on the form when it is rendered.

writer.Write("<input type=\"hidden\" id=\"" + this.ID + "_OffsetY\" name=\"" + this.ID + "_OffsetY\" value=\"0\">\n");
writer.Write("<input type=\"hidden\" id=\"" + this.ID + "_OffsetX\" name=\"" + this.ID + "_OffsetX\" value=\"0\">\n");

It attaches the scrolling functions to the page's onscroll. (Rest you can remove from the code available with the article.)

When page is loaded after postback. Following code fragment of the control gets executed:

if (Page.IsPostBack )

{

writer.Write("function " + this.ID + "_OnLoad(){\n");

writer.Write("var xVal = " + Page.Request.Form[this.ID + "_OffsetX"] + ";\n");

writer.Write("var yVal = " + Page.Request.Form[this.ID + "_OffsetY"] + ";\n");
writer.Write("window.scrollTo(xVal,yVal);\n");

writer.Write("}\n");

writer.Write("if (!isIE){\n");

writer.Write("window.addEventListener('load'," + this.ID + "_OnLoad, false);\n");

writer.Write("}\n"); 

writer.Write("else{\n");

writer.Write("window.attachEvent('onload'," + this.ID + "_OnLoad);\n");

writer.Write("}\n");

How to use it?

SmartNavigationFixupModule control is very easy to use. It being a custom control, you just need to add it to the toolbox. Drag the control and place it on the web page. No coding is required, rest of the things will be handled by the control .

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
Software Developer with 5+ Years of experience.

Comments and Discussions

 
GeneralProblem with validation script when SmartNavigation is true Pin
Talal Sultan15-May-06 1:41
Talal Sultan15-May-06 1:41 
GeneralIt does not work Pin
fcojavilg5-Mar-06 9:19
fcojavilg5-Mar-06 9:19 
GeneralRe: It does not work Pin
NeeruVerma7-Mar-06 18:09
NeeruVerma7-Mar-06 18:09 
GeneralRe: It does not work Pin
fcojavilg13-Mar-06 3:34
fcojavilg13-Mar-06 3:34 
GeneralDoesn't work Pin
Baelzharon25-Jan-06 5:45
Baelzharon25-Jan-06 5:45 
GeneralRe: Doesn't work Pin
NeeruVerma26-Jan-06 17:55
NeeruVerma26-Jan-06 17:55 
GeneralRe: Doesn't work Pin
Baelzharon27-Jan-06 2:22
Baelzharon27-Jan-06 2:22 
GeneralRe: Doesn't work Pin
NeeruVerma27-Jan-06 17:42
NeeruVerma27-Jan-06 17:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.