A
André
Hi,
i get sometimes an very unexpected error:
"A form tag with runat=server must exist on the Page to use SetFocus() or
the Focus property"
at line: If j = 1 Then txta(i).Focus()
There is a form tag as you can see in the aspx file. Is there any other
reason for this error?
Thanks for help
André
The aspx code is this:
<%@ Page Language="VB" MaintainScrollPositionOnPostback="true"
AutoEventWireup="false" CodeFile="~/myfile.aspx.vb" Inherits="myfile" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"><title>Untitled Page</title></head>
<body>
<form id="form1" runat="server">
<div style="text-align: center">
<asp:Label ID="Label1" runat="server" ></asp:Label>
</div>
<div style="text-align: center">
<asp:Label ID="Label1" runat="server" Font-Bold="True"></asp:Label>
</div>
</form>
</body>
</html>
The code-behind:
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreInit
........
txta(i) = New TextBox
txta(i).TextMode = TextBoxMode.MultiLine
frm.Controls.Add(txta(i))
If j = 1 Then txta(i).Focus()
........
i get sometimes an very unexpected error:
"A form tag with runat=server must exist on the Page to use SetFocus() or
the Focus property"
at line: If j = 1 Then txta(i).Focus()
There is a form tag as you can see in the aspx file. Is there any other
reason for this error?
Thanks for help
André
The aspx code is this:
<%@ Page Language="VB" MaintainScrollPositionOnPostback="true"
AutoEventWireup="false" CodeFile="~/myfile.aspx.vb" Inherits="myfile" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"><title>Untitled Page</title></head>
<body>
<form id="form1" runat="server">
<div style="text-align: center">
<asp:Label ID="Label1" runat="server" ></asp:Label>
</div>
<div style="text-align: center">
<asp:Label ID="Label1" runat="server" Font-Bold="True"></asp:Label>
</div>
</form>
</body>
</html>
The code-behind:
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreInit
........
txta(i) = New TextBox
txta(i).TextMode = TextBoxMode.MultiLine
frm.Controls.Add(txta(i))
If j = 1 Then txta(i).Focus()
........