473,323 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

SmartNavigation + AutoPostBack

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

1. Main ASPX page is populated with several "Questions".
2. Within the code of the main page, there is a SelectedIndexChanged handler
for the RadioButtonList exposed by Question. The function loops through a
number of questions on the pages and hides/shows questions (control.visible
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 "SmartNavigation" 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 1757
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.dataworx.be> wrote in message
news:u0**************@TK2MSFTNGP10.phx.gbl...
A web user control exposes a RadioButtonList (with AutoPostBack = true)
called "Question". This control also has an embedded RequiredFieldValidator control.

1. Main ASPX page is populated with several "Questions".
2. Within the code of the main page, there is a SelectedIndexChanged handler for the RadioButtonList exposed by Question. The function loops through a
number of questions on the pages and hides/shows questions (control.visible 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 "SmartNavigation" 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.dataworx.be> wrote...
A web user control exposes a RadioButtonList (with AutoPostBack = true)
called "Question". This control also has an embedded RequiredFieldValidator control.

1. Main ASPX page is populated with several "Questions".
2. Within the code of the main page, there is a SelectedIndexChanged handler for the RadioButtonList exposed by Question. The function loops through a
number of questions on the pages and hides/shows questions (control.visible 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 "SmartNavigation" 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.vb:

Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents ValidationSummary1 As
System.Web.UI.WebControls.ValidationSummary
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents PlaceHolder1 As System.Web.UI.WebControls.PlaceHolder

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

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

Me.SmartNavigation = True

Dim i As Integer
Dim c As UserControl

For i = 1 To 10
c = New UserControl()
c = CType(LoadControl("WebUserControl1.ascx"), WebUserControl1)
CType(c, WebUserControl1).InitQuestion(i)

FindControl("PlaceHolder1").Controls.Add(c)
Next
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If IsPostBack Then
Dim c As UserControl
For Each c In FindControl("PlaceHolder1").Controls
If CType(c, WebUserControl1).QID = 5 Then
If CType(c, WebUserControl1).RadioButtonList.SelectedIndex = 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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.Validate()

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

2) WebUserControl1.ascx.vb:

Public MustInherit Class WebUserControl1
Inherits System.Web.UI.UserControl
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents RequiredFieldValidator1 As
System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RadioButtonList1 As
System.Web.UI.WebControls.RadioButtonList

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

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

Me.RadioButtonList1.AutoPostBack = True
End Sub

#End Region

Private mintQID As Integer

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

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

Public Sub InitQuestion(ByVal QID As Integer)
mintQID = QID
Label1.Text = "Question " & mintQID.ToString()

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

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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
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...
2
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...
4
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...
3
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...
2
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...
0
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. ...
5
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...
0
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 ...
1
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.