Showing posts with label runatserver. Show all posts
Showing posts with label runatserver. Show all posts

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.

A Blug in ModalPopup

The ModalPopup will be covered by dropdownlist if there is dropdownlist in ContentTemplate

<atlas:UpdatePanel runat=server ID=update1 > <ContentTemplate><asp:DropDownList ID=zoneType runat=server Width="132px" ><asp:ListItem Value=1>other</asp:ListItem></asp:DropDownList>
      ....

This is discussed in a couple of other posts in this forum (please search for details). Briefly, IE creates actual window controls for stuff like this and they aren't subject to the normal layering rules of the page.