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 following 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.
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\M ultiViewTest.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\M ultiViewTest.aspx.cs:21
System.Web.UI.WebControls.View.OnActivate(EventArg s e) +105
System.Web.UI.WebControls.MultiView.set_ActiveView Index(Int32 value) +395
System.Web.UI.WebControls.MultiView.OnInit(EventAr gs 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.CreateControlHier archy() +2992
System.Web.UI.WebControls.Wizard.CreateChildContro ls() +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) +692On further investigation it seems that i can't set the focus on any control
from within the activate event. I have no problems however, setting the
focus onto the textbox controls within the wizardsetps, from the Page_load
event
"clickon" wrote:
> 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 following 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.
> 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\M ultiViewTest.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\M ultiViewTest.aspx.cs:21
> System.Web.UI.WebControls.View.OnActivate(EventArg s e) +105
> System.Web.UI.WebControls.MultiView.set_ActiveView Index(Int32 value) +395
> System.Web.UI.WebControls.MultiView.OnInit(EventAr gs 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.CreateControlHier archy() +2992
> System.Web.UI.WebControls.Wizard.CreateChildContro ls() +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
0 comments:
Post a Comment