472,378 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,378 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 1702
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.