T
tshad
I am trying to put together a user control (.ascx).
Can you access an outside control from it?
My control:
login2.ascx
****************************************************************
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
if not IsPostBack
myBody.Attributes.Add("onLoad","document.forms[0].UserName.focus()")
UserName.Text = "This is a test"
else
end if
End Sub
</script>
<table border="0" width="106%" >
<tr valign="baseline">
<td width="99" align="right" valign="middle" nowrap >User Name :</td>
<td width="500" align="left" >
<asp:textbox id="UserName" TextMode="SingleLine" Columns="25"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="UserName"
Text="User Name Required"
runat="server" />
</td>
</tr>
</table>
****************************************************************
I get an error on access "mybody" as:
Name 'myBody' is not declared.
My aspx file looks essentially like:
**************************************************************
<html>
<%@ Register TagPrefix="fts" TagName="Login" Src="login2.ascx" %>
<head>
<title>:: Staffing Workshop ::</title>
</head>
<body id="myBody" runat="server">
<form runat="server">
<fts:Login runat="server"/>
</form>
</body>
</html>
**************************************************************
If I comment the line:
' myBody.Attributes.Add("onLoad","document.forms[0].UserName.focus()")
it works fine.
Is there a way to access this outside body tag from my control?
Thanks,
Tom
Can you access an outside control from it?
My control:
login2.ascx
****************************************************************
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
if not IsPostBack
myBody.Attributes.Add("onLoad","document.forms[0].UserName.focus()")
UserName.Text = "This is a test"
else
end if
End Sub
</script>
<table border="0" width="106%" >
<tr valign="baseline">
<td width="99" align="right" valign="middle" nowrap >User Name :</td>
<td width="500" align="left" >
<asp:textbox id="UserName" TextMode="SingleLine" Columns="25"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="UserName"
Text="User Name Required"
runat="server" />
</td>
</tr>
</table>
****************************************************************
I get an error on access "mybody" as:
Name 'myBody' is not declared.
My aspx file looks essentially like:
**************************************************************
<html>
<%@ Register TagPrefix="fts" TagName="Login" Src="login2.ascx" %>
<head>
<title>:: Staffing Workshop ::</title>
</head>
<body id="myBody" runat="server">
<form runat="server">
<fts:Login runat="server"/>
</form>
</body>
</html>
**************************************************************
If I comment the line:
' myBody.Attributes.Add("onLoad","document.forms[0].UserName.focus()")
it works fine.
Is there a way to access this outside body tag from my control?
Thanks,
Tom