Possible bug?

G

Guest

I have posted this question 3 times now and no-one has even answered it, so
is it possibly a bug or am i missing something. In short it does not seem to
be possible to set the focus on control from within the Active event handler
of the WizardStep control. Full details below.

For testing purposes i have got a 2 step WizardControl. Eqach step contains
a text box, TextBox1 and TextBox2 respectively. If i put the following code
in the respective activate event handlers for the two steps,

TextBox1.Text ="foo";

and

TextBox2.Text = "bar";

Then in the first step the TextBox (TextBox1) contains the word foo and in
the second step the TextBox (TextBox2) contains the word bar. As you would
expect.

However if i replace the code with

TextBox1.Focus();

and

TextBox2.Focus();

Then i get the below error and i can't understand why. This is the
first time i have used Wizard controls and i'm just trying to work out how
they behave. What am i missing about Wizard controls that is causing this
behaviour. Also it does not matter whether the textboxes are within the
wizardstep or not, you cannot seem to set the focus to any control from
within the Active event handler of the WizardStep control. If you call the
focus method from the Page_load event handler then it works fine.

Anyone any idea what is causing this, i have called the focus method from
within other event handlers such as the OnDataBound event and the OnClick
event with no problem.


Error details:

A form tag with runat=server must exist on the Page to use SetFocus() or
the Focus property.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.InvalidOperationException: A form tag with
runat=server must exist on the Page to use SetFocus() or the Focus property.

Source Error:

Line 19: protected void WizardStep1_Activate(object sender, EventArgs e)
Line 20: {
Line 21: TextBox1.Focus();
Line 22:
Line 23: }


Source File:
E:\DevelopmentWebsite\IntranetDev\Portal\Testing\MultiViewTest.aspx.cs
Line: 21

Stack Trace:

[InvalidOperationException: A form tag with runat=server must exist on the
Page to use SetFocus() or the Focus property.]
System.Web.UI.Page.SetFocus(Control control) +2021658
System.Web.UI.Control.Focus() +20
Testing_MultiViewTest.WizardStep1_Activate(Object sender, EventArgs e) in
E:\DevelopmentWebsite\IntranetDev\Portal\Testing\MultiViewTest.aspx.cs:21
System.Web.UI.WebControls.View.OnActivate(EventArgs e) +105
System.Web.UI.WebControls.MultiView.set_ActiveViewIndex(Int32 value) +395
System.Web.UI.WebControls.MultiView.OnInit(EventArgs e) +46
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.AddedControl(Control control, Int32 index) +2065279
System.Web.UI.ControlCollection.Add(Control child) +146
System.Web.UI.WebControls.Wizard.CreateControlHierarchy() +2992
System.Web.UI.WebControls.Wizard.CreateChildControls() +126
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) +100
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692
 
P

Patrice

I would code to see if I can find the form parent control. Could it be
because the whole hierarchy is not totally build yet at this time ?

--
Patrice

clickon said:
I have posted this question 3 times now and no-one has even answered it, so
is it possibly a bug or am i missing something. In short it does not seem
to
be possible to set the focus on control from within the Active event
handler
of the WizardStep control. Full details below.

For testing purposes i have got a 2 step WizardControl. Eqach step
contains
a text box, TextBox1 and TextBox2 respectively. If i put the following
code
in the respective activate event handlers for the two steps,

TextBox1.Text ="foo";

and

TextBox2.Text = "bar";

Then in the first step the TextBox (TextBox1) contains the word foo and in
the second step the TextBox (TextBox2) contains the word bar. As you would
expect.

However if i replace the code with

TextBox1.Focus();

and

TextBox2.Focus();

Then i get the below error and i can't understand why. This is the
first time i have used Wizard controls and i'm just trying to work out how
they behave. What am i missing about Wizard controls that is causing this
behaviour. Also it does not matter whether the textboxes are within the
wizardstep or not, you cannot seem to set the focus to any control from
within the Active event handler of the WizardStep control. If you call
the
focus method from the Page_load event handler then it works fine.

Anyone any idea what is causing this, i have called the focus method from
within other event handlers such as the OnDataBound event and the OnClick
event with no problem.


Error details:

A form tag with runat=server must exist on the Page to use SetFocus() or
the Focus property.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.InvalidOperationException: A form tag with
runat=server must exist on the Page to use SetFocus() or the Focus
property.

Source Error:

Line 19: protected void WizardStep1_Activate(object sender, EventArgs e)
Line 20: {
Line 21: TextBox1.Focus();
Line 22:
Line 23: }


Source File:
E:\DevelopmentWebsite\IntranetDev\Portal\Testing\MultiViewTest.aspx.cs
Line: 21

Stack Trace:

[InvalidOperationException: A form tag with runat=server must exist on the
Page to use SetFocus() or the Focus property.]
System.Web.UI.Page.SetFocus(Control control) +2021658
System.Web.UI.Control.Focus() +20
Testing_MultiViewTest.WizardStep1_Activate(Object sender, EventArgs e) in
E:\DevelopmentWebsite\IntranetDev\Portal\Testing\MultiViewTest.aspx.cs:21
System.Web.UI.WebControls.View.OnActivate(EventArgs e) +105
System.Web.UI.WebControls.MultiView.set_ActiveViewIndex(Int32 value) +395
System.Web.UI.WebControls.MultiView.OnInit(EventArgs e) +46
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.AddedControl(Control control, Int32 index) +2065279
System.Web.UI.ControlCollection.Add(Control child) +146
System.Web.UI.WebControls.Wizard.CreateControlHierarchy() +2992
System.Web.UI.WebControls.Wizard.CreateChildControls() +126
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) +100
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692
 
G

Guest

I suspect it most be something like that, but i was hoping someone might know
at what point the active event for a WizardStep control. I have never had a
problem calling the focus method on a control from any other event.

Could you give me an example of "code to find the parent control" because i
am not sure what you mean by this. Calling focus on any textbox, wherever it
is within the page causes this error.

Patrice said:
I would code to see if I can find the form parent control. Could it be
because the whole hierarchy is not totally build yet at this time ?

--
Patrice

clickon said:
I have posted this question 3 times now and no-one has even answered it, so
is it possibly a bug or am i missing something. In short it does not seem
to
be possible to set the focus on control from within the Active event
handler
of the WizardStep control. Full details below.

For testing purposes i have got a 2 step WizardControl. Eqach step
contains
a text box, TextBox1 and TextBox2 respectively. If i put the following
code
in the respective activate event handlers for the two steps,

TextBox1.Text ="foo";

and

TextBox2.Text = "bar";

Then in the first step the TextBox (TextBox1) contains the word foo and in
the second step the TextBox (TextBox2) contains the word bar. As you would
expect.

However if i replace the code with

TextBox1.Focus();

and

TextBox2.Focus();

Then i get the below error and i can't understand why. This is the
first time i have used Wizard controls and i'm just trying to work out how
they behave. What am i missing about Wizard controls that is causing this
behaviour. Also it does not matter whether the textboxes are within the
wizardstep or not, you cannot seem to set the focus to any control from
within the Active event handler of the WizardStep control. If you call
the
focus method from the Page_load event handler then it works fine.

Anyone any idea what is causing this, i have called the focus method from
within other event handlers such as the OnDataBound event and the OnClick
event with no problem.


Error details:

A form tag with runat=server must exist on the Page to use SetFocus() or
the Focus property.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.InvalidOperationException: A form tag with
runat=server must exist on the Page to use SetFocus() or the Focus
property.

Source Error:

Line 19: protected void WizardStep1_Activate(object sender, EventArgs e)
Line 20: {
Line 21: TextBox1.Focus();
Line 22:
Line 23: }


Source File:
E:\DevelopmentWebsite\IntranetDev\Portal\Testing\MultiViewTest.aspx.cs
Line: 21

Stack Trace:

[InvalidOperationException: A form tag with runat=server must exist on the
Page to use SetFocus() or the Focus property.]
System.Web.UI.Page.SetFocus(Control control) +2021658
System.Web.UI.Control.Focus() +20
Testing_MultiViewTest.WizardStep1_Activate(Object sender, EventArgs e) in
E:\DevelopmentWebsite\IntranetDev\Portal\Testing\MultiViewTest.aspx.cs:21
System.Web.UI.WebControls.View.OnActivate(EventArgs e) +105
System.Web.UI.WebControls.MultiView.set_ActiveViewIndex(Int32 value) +395
System.Web.UI.WebControls.MultiView.OnInit(EventArgs e) +46
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.AddedControl(Control control, Int32 index) +2065279
System.Web.UI.ControlCollection.Add(Control child) +146
System.Web.UI.WebControls.Wizard.CreateControlHierarchy() +2992
System.Web.UI.WebControls.Wizard.CreateChildControls() +126
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) +100
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top