473,569 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UserControl?

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>Passwo rd : "
& pwd.Text"
End Sub
</script>
<table style="backgrou nd-color:<%= BColor %>;" cellspacing=5>
<tr>
<td>Login:</td>
<td><asp:TextBo x id="uid" runat="server"/></td>
</tr>
<tr>
<td>Password: </td>
<td><asp:TextBo x id="pwd" TextMode="Passw ord" runat="server"/></td>
</tr>
<tr>
<td><asp:Butt on text="SUBMIT" OnClick="btnSub mit" 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="Sign In" 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.UNa me & "<br>"
lblMessage.Text += "Password: " & UCLoginForm.UPw d" & "<br>"
lblMessage.Text += "BackColor: " & UCLoginForm.BCo lor
End Sub
</script>
<html>
<body>
<form runat="server">
<SignIn:ULogi n 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
0 1133

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7111
by: Dave Veeneman | last post by:
Is there a simple way to pass drag-and-drop events to a child control in a UserControl? Here's an example: I have created a UserControl which contains a treeview and some text boxes. I want to be able to drag-and-drop to the treeview from outside the UserControl. Now, when I drag over the treeview in the UserControl, the UserControl gets...
8
1952
by: Raed Sawalha | last post by:
Hi, I have a strange problem with a usercontrol on a page. The usercontrol dispalyes three categories (From a database) when the user clicks a category they see all the products in a shop for that category, the results are paged 10 to a page and the user can page them. As this "Category" usercontrol hardly ever changes I wanted to setup...
2
2236
by: Eric Maia | last post by:
I have two UserControls I am using in a form. These are each also used separately in two other forms. The structure is essentially this: CourseUserControl.ascx - select or enter a course SessionUserControl.ascx - select or enter a course session CourseDetails.aspx - a form which contains just CourseUserControl CourseSessionDetails.aspx -...
2
4612
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation for me! I apologize for the length of this posting, but I wanted to make sure that I get an answer other than "Hey man, just use LoadControl!",...
41
4266
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based on some initialization information obtained elsewhere. Basically, I'm going to create my own dynamic toolbar where the toolbarbuttons can change. ...
12
2186
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control server. It "serves" back the required control (either WebControl or UserControl) based on the contents of an xml file. The code in the webform places...
9
14431
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it does not. The problem is that the webcontrols get created on the OnLoad event of the usercontrol and the event handlers are assigned at the same...
5
19650
by: Blue | last post by:
We have a custom word processing type editor built with C# and .NET 2.0 and we need to support typing in languages other than English. I want to be able to use the Windows IME to enter in text similar to how it works in a text box. For example, if I put focus on a TextBox and then switch my language on the language bar to Japanese or...
6
12125
by: MeowCow | last post by:
I have created a UserControl that encapsulates a third party data grid. My goal was to create my own DataSource and DataMember properties that forward the binding to the third party grid, then use binding like normal. The problem I am running into is that my UserControl ends up with a different BindingContext then the ParentForm it is...
10
2406
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's my question. Once the UserControl is dropped onto the container page, how can I perform some action on the codebehind of the container page from...
0
7697
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7672
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7968
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.