473,609 Members | 1,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SmartNavigation + AutoPostBack

SLE
A web user control exposes a RadioButtonList (with AutoPostBack = true)
called "Question". This control also has an embedded RequiredFieldVa lidator
control.

1. Main ASPX page is populated with several "Questions" .
2. Within the code of the main page, there is a SelectedIndexCh anged handler
for the RadioButtonList exposed by Question. The function loops through a
number of questions on the pages and hides/shows questions (control.visibl e
property) depending on answers of other questions.

All works fine until I press the submit button which forces a
Me.Validate() - if there are any errors because of unanswered questions, the
above system no longer works.

If I disable "SmartNavigatio n" everyhting works fine but I need it because
of the postbacks which cause unacceptable scrolling (d)effects...

Any clues?
Thanks,
SLE
Nov 18 '05 #1
2 1783
JL
Last time i used smartnavigation it was buggy.

I use a modified version of this javascript instead:

http://groups.google.ca/groups?hl=fr...n.co.uk&rnum=3

JL

"SLE" <in**@NOSPAM.da taworx.be> wrote in message
news:u0******** ******@TK2MSFTN GP10.phx.gbl...
A web user control exposes a RadioButtonList (with AutoPostBack = true)
called "Question". This control also has an embedded RequiredFieldVa lidator control.

1. Main ASPX page is populated with several "Questions" .
2. Within the code of the main page, there is a SelectedIndexCh anged handler for the RadioButtonList exposed by Question. The function loops through a
number of questions on the pages and hides/shows questions (control.visibl e property) depending on answers of other questions.

All works fine until I press the submit button which forces a
Me.Validate() - if there are any errors because of unanswered questions, the above system no longer works.

If I disable "SmartNavigatio n" everyhting works fine but I need it because
of the postbacks which cause unacceptable scrolling (d)effects...

Any clues?
Thanks,
SLE

Nov 18 '05 #2
SLE
"SLE" <in**@NOSPAM.da taworx.be> wrote...
A web user control exposes a RadioButtonList (with AutoPostBack = true)
called "Question". This control also has an embedded RequiredFieldVa lidator control.

1. Main ASPX page is populated with several "Questions" .
2. Within the code of the main page, there is a SelectedIndexCh anged handler for the RadioButtonList exposed by Question. The function loops through a
number of questions on the pages and hides/shows questions (control.visibl e property) depending on answers of other questions.

All works fine until I press the submit button which forces a
Me.Validate() - if there are any errors because of unanswered questions, the above system no longer works.

If I disable "SmartNavigatio n" everyhting works fine but I need it because
of the postbacks which cause unacceptable scrolling (d)effects...


This is a repro. The following simple example creates some questions (via a
web user control) on the main ASPX page. It demonstrates what I want to do,
i.e. if the answer to question 5 equals "1", question 6 should disappear.
Everything works fine until the submit button is invoked. From then on, I
cannot hide questions (though .Visible = False is stepped into). When
turning off smartnavigation , it works. Having smartnavigation without the
required field validator control works fine too...

1) WebForm1.aspx.v b:

Public Class WebForm1
Inherits System.Web.UI.P age
Protected WithEvents ValidationSumma ry1 As
System.Web.UI.W ebControls.Vali dationSummary
Protected WithEvents Button1 As System.Web.UI.W ebControls.Butt on
Protected WithEvents PlaceHolder1 As System.Web.UI.W ebControls.Plac eHolder

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()

Me.SmartNavigat ion = True

Dim i As Integer
Dim c As UserControl

For i = 1 To 10
c = New UserControl()
c = CType(LoadContr ol("WebUserCont rol1.ascx"), WebUserControl1 )
CType(c, WebUserControl1 ).InitQuestion( i)

FindControl("Pl aceHolder1").Co ntrols.Add(c)
Next
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If IsPostBack Then
Dim c As UserControl
For Each c In FindControl("Pl aceHolder1").Co ntrols
If CType(c, WebUserControl1 ).QID = 5 Then
If CType(c, WebUserControl1 ).RadioButtonLi st.SelectedInde x = 0 Then
GetUserControl( 6).Visible = False
Else
GetUserControl( 6).Visible = True
End If
End If
Next
End If
End Sub

Private Function GetUserControl( ByVal questionID As Integer) As
WebUserControl1
Dim c As Control

For Each c In Me.FindControl( "PlaceHolder1") .Controls
If CType(c, WebUserControl1 ).QID = questionID Then
Return CType(c, WebUserControl1 )
End If
Next
End Function

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Me.Validate()

If Me.IsValid Then
Response.Redire ct("about:blank ")
End If
End Sub
End Class

2) WebUserControl1 .ascx.vb:

Public MustInherit Class WebUserControl1
Inherits System.Web.UI.U serControl
Protected WithEvents Panel1 As System.Web.UI.W ebControls.Pane l
Protected WithEvents Label1 As System.Web.UI.W ebControls.Labe l
Protected WithEvents RequiredFieldVa lidator1 As
System.Web.UI.W ebControls.Requ iredFieldValida tor
Protected WithEvents RadioButtonList 1 As
System.Web.UI.W ebControls.Radi oButtonList

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()

Me.RadioButtonL ist1.AutoPostBa ck = True
End Sub

#End Region

Private mintQID As Integer

Public ReadOnly Property RadioButtonList () As RadioButtonList
Get
Return RadioButtonList 1
End Get
End Property

Public ReadOnly Property QID() As Integer
Get
Return mintQID
End Get
End Property

Public Sub InitQuestion(By Val QID As Integer)
mintQID = QID
Label1.Text = "Question " & mintQID.ToStrin g()

With RadioButtonList 1.Items
.Add("1")
.Add("2")
.Add("3")
End With
End Sub

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

End Class
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1000
by: Grober | last post by:
Steve C. Orr was kind enough to help find SmartNavigation, and it worked fine when I had my aspx page locally on my computer. However, when I publish it, the problem is still the same: when the page is reloaded after a dropdownlist's contents has been modified I have to scroll down to where I was again. What could be the difference? Regards /Grober
2
1251
by: Mark Goldin | last post by:
I am trying to use SmartNavigation="true" in my Page directive. My page has two radiobuttons. Both buttons have AutoPostBack enabled. When I am clicking on the buttons they are changing data source for a treeview. (assigning different XML file). When I use localhost everything works properly, but using IP in a place of localhost is not working too good. After a few clicks the tree is not getting new data, Windows flag is waiving, and a...
4
1507
by: Bobby | last post by:
Hi all... I rather confuse using smartnavigation in my web application because if I set the "smartnavigation = true" then If I run my app, then after I post page that page, using event dropdownlist1_selectedIndexChanged then the page would't get the css, and then the IE will generate error confirmation dialog, then my browser will be closed. I'm using iframe for my app, 2 frame -> top frame and content frame. I use smartnavigation for...
3
1876
by: Nestus | last post by:
Hi, im developing a solution in ASP.Net, i have a page that i need to use the smartnavigation in true, the problem occurs when i put in the directive @Page SmartNavigation = true my page trhows a error in the next line, i really dont understand why the page trhows that error. Here is the line that make the error. Response.Write("<script language=javascript>window.parent.frames.location='OpcionReporte.a spx';</script>")
2
2008
by: Wysiwyg | last post by:
Has anyone found a reasonable way to emulate smartnavigation functionality for any browser? I'd really like to avoid creating history entries when posting back to the same page. SmartNavigation takes care of the annoying problem caused by creating a new history entry when a page posts to itself. Only Internet Explorer will support this functionality. When SmartNavigation is enabled the client executes javascript code from the SmartNav.js...
0
975
by: catweezle2010 | last post by:
Hello NG, I need autopostback to verify the user's input. They have to fill in the number of pices to order and I have to check each time if the allowed number is reached and something more. This function works fine. The Problem is, that the autopostback will take affect, when the user left the control for an other. Here he starts the new input. Meanwhile the postback takes effect and publish the new calculated site. The smartnavigation...
5
4266
by: Mogens Nielsen - Elbek & Vejrup A/S | last post by:
Hi, I can see from the msdn-docs that SmartNavigation is now obsolete. Why is that? The SmartNavigation feature has been replaced by MaintainScrollPosition, but the scoll position is not why we're using the feature. It is mainly to avoid the flickering when posting back. However we've got another project running, for which we would like to turn SmartNavigation on, as we have an idea, that it will cause McAfee ScriptScan to scan less...
0
935
by: manika02 | last post by:
I know this is a bug with SmartNavigation that if your controls have AutoPostBack = true, the cursor won't come back to the same control. I went through this article http://support.microsoft.com/kb/314206 But is there another solution to this problem. If yes, Please let me know. Thanks
1
2098
by: danyeungw | last post by:
I get the following from the link http://support.microsoft.com/kb/314206. I need to have both work - the page stays where it is and set focus to next control. Does anyone have solution? I have been working on this for days. I am using ASP.NET 2003. Thanks. DanYeung PRB: Controls Lose Focus When You Enable SmartNavigation and AutoPostBack View products that this article applies to. Article ID : 314206 Last Review : February 23,...
0
8139
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8579
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8232
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6064
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5524
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4032
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4098
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1686
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.