By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,908 Members | 2,041 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,908 IT Pros & Developers. It's quick & easy.

UserControl?

P: n/a
I have created the following UserControl (the file is named
LoginForm.ascx):

<script language=VB runat="server">
Public UName As String
Public UPwd As String
Public BColor As String

Public Sub btnSubmit(ByVal obj As Object, ByVal ea As EventArgs)
lblMessage.Text = "UserName : " & uid.Text & "<br>Password : "
& pwd.Text"
End Sub
</script>
<table style="background-color:<%= BColor %>;" cellspacing=5>
<tr>
<td>Login:</td>
<td><asp:TextBox id="uid" runat="server"/></td>
</tr>
<tr>
<td>Password:</td>
<td><asp:TextBox id="pwd" TextMode="Password" runat="server"/></td>
</tr>
<tr>
<td><asp:Button text="SUBMIT" OnClick="btnSubmit" runat="server"/></td>
</tr>
</table>
<asp:Label id="lblMessage" runat="server"/>

& this is the ASPX page (named LoginForm.aspx) that uses the above
UserControl:

<%@ Page Language="VB" %>
<%@ Register TagPrefix="SignIn" TagName="ULogin" Src="LoginForm.ascx"
%>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
lblMessage.Text = "Properties of the user control: <br>"
lblMessage.Text += "ID: " & UCLoginForm.ID & "<br>"
lblMessage.Text += "UserName: " & UCLoginForm.UName & "<br>"
lblMessage.Text += "Password: " & UCLoginForm.UPwd" & "<br>"
lblMessage.Text += "BackColor: " & UCLoginForm.BColor
End Sub
</script>
<html>
<body>
<form runat="server">
<SignIn:ULogin id="UCLoginForm" UName="MyUName" UPwd="MyPwd"
BColor="pink" runat="server" />
</form>
<asp:Label id="lblMessage" runat="server" />
</body>
</html>

The above code works well but VWD 2005 generates the following warning
for each of the 3 properties of the UserControl i.e."UName", "UPwd" &
"BColor" in LoginForm.aspx (the errors pop-up when the mouse is hovered
over the 3 properties):

Validation (ASP.NET): Attribute 'UName' is not a valid attribute of
element 'ULogin'.

VWD generates the same warning for the properties "UPwd" & "BColor".
Why so inspite of the fact that the ASPX page gets executed in the
browser without any problems?

Getting back to the UserControl file i.e. LoginForm.ascx - VWD
generates the following syntax error pointing to the "table" tag in
LoginForm.ascx:

Validation (Internet Explorer 6): Element 'table' must be included
within a parent element.

VWD also generates the above error pointing to the <ptag.

Apart from this, VWD also generates the following syntax error pointing
to all the "asp" tag prefixes in LoginForm.ascx:

Unrecognized tag prefix or device filter 'asp'.

First of all, can't the "asp" tag prefix be used in an ASCX file? If
not, then what tag prefix need to be used to create the different Web
Server controls in an ASCX file?

Lastly, why is the ASPX page getting executed in the browser without
any problems/errors when both the ASPX & the ASCX files are generating
the above mentioned errors?

Thanks,

Arpan

Jul 26 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.