Wednesday, March 21, 2012

A form tag with runat=server must exist on the Page to use SetFocus() or the Focus propert

Hi there,

I have a Multiview control with Views. Right now I'm trying to set focus to a textbox using the Activate event of one of the Views, like this:

protected void vieSearchShipment_Activate(object sender, EventArgs e)
{
this.Setfocus(tbxShipment);
}

This is my Setfocus method:

protected void Setfocus(TextBox textBox)
{
(this.Master.FindControl("ScriptManager1") as Microsoft.Web.UI.ScriptManager).SetFocus(textBox);
}

But when I call the Setfocus() method from the View's Activate event, I get this exception:

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

The textBox is inside the View and is visible, of course. So what am I missing?

Thanks in advance,

-Benton

Check your <form ... > to see if you miss the runat=server or not.

WS


hi

i got error when i use focus property like this

error:

Invalid operation Exception Unhandled by user code,

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


my code:

protected void Page_Load(object sender, EventArgs e)
{
this.lgnUsers.Focus();
}

please help me



See the answer to your other post inthis thread.

No comments:

Post a Comment