UserControl?

A

Arpan

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 <p> tag.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top