Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Error Setting user control property at web form

Reply
Thread Tools

Error Setting user control property at web form

 
 
Amir Eshterayeh
Guest
Posts: n/a
 
      11-27-2003
Dear Friends
Hope things goes well to you. I have this problem. Would you please give me
your solution?

I want to change a property that I define on my user control in my web form
that contains that user control.
but when I want to set the property of user control at my web form, got this
error
c:\inetpub\wwwroot\test4\WebForm1.aspx.vb(19): Name 'Uc1' is not declared.
How can I solve this problem. Please help.
Thank you very much in advance and please me your answer to my email:
http://www.velocityreviews.com/forums/(E-Mail Removed) if possible.

Best Regards
Amir Eshterayeh
(E-Mail Removed)


this is the code behind (vb code) of my web form

----------------------------------------------------------------------------
-----------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Uc1.Username = "Message text changed!"
End Sub
----------------------------------------------------------------------------
-----------------------------

This is the user control code
----------------------------------------------------------------------------
-----------------------------

Public MustInherit Class uc
Inherits System.Web.UI.UserControl
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Public Username As String

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Label1.Text = Username
End Sub

End Class
----------------------------------------------------------------------------
-----------------------------
this is the user control HTML
----------------------------------------------------------------------------
-----------------------------

<%@ Control Language="vb" AutoEventWireup="false" Codebehind="uc.ascx.vb"
Inherits="test4.uc"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>

<asp:Label id="Label1" runat="server">Label</asp:Label>
----------------------------------------------------------------------------
-----------------------------
this is the HTML Code my Web form that contains my user control
----------------------------------------------------------------------------
-----------------------------
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="test4.WebForm1"%>
<%@ Register TagPrefix="uc1" TagName="uc" Src="uc.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">

<uc1:uc id="Uc1" runat="server"></uc1:uc>

</form>
</body>
</HTML>
----------------------------------------------------------------------------
-----------------------------



 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      11-27-2003
Hi,

You need to have a member declaration for the user control at the Page as
you have already for the Label in the user control.That means a member whose
name matches the ID of the user control and type matches the code-behinc
class type of the UC.

Protected WithEvents Uc1 As uc

(Please do not cross-post)

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist


"Amir Eshterayeh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Dear Friends
> Hope things goes well to you. I have this problem. Would you please give

me
> your solution?
>
> I want to change a property that I define on my user control in my web

form
> that contains that user control.
> but when I want to set the property of user control at my web form, got

this
> error
> c:\inetpub\wwwroot\test4\WebForm1.aspx.vb(19): Name 'Uc1' is not

declared.
> How can I solve this problem. Please help.
> Thank you very much in advance and please me your answer to my email:
> (E-Mail Removed) if possible.
>
> Best Regards
> Amir Eshterayeh
> (E-Mail Removed)
>
>
> this is the code behind (vb code) of my web form
>
> --------------------------------------------------------------------------

--
> -----------------------------
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Uc1.Username = "Message text changed!"
> End Sub
> --------------------------------------------------------------------------

--
> -----------------------------
>
> This is the user control code
> --------------------------------------------------------------------------

--
> -----------------------------
>
> Public MustInherit Class uc
> Inherits System.Web.UI.UserControl
> Protected WithEvents Label1 As System.Web.UI.WebControls.Label
> Public Username As String
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> Label1.Text = Username
> End Sub
>
> End Class
> --------------------------------------------------------------------------

--
> -----------------------------
> this is the user control HTML
> --------------------------------------------------------------------------

--
> -----------------------------
>
> <%@ Control Language="vb" AutoEventWireup="false" Codebehind="uc.ascx.vb"
> Inherits="test4.uc"
> TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
>
> <asp:Label id="Label1" runat="server">Label</asp:Label>
> --------------------------------------------------------------------------

--
> -----------------------------
> this is the HTML Code my Web form that contains my user control
> --------------------------------------------------------------------------

--
> -----------------------------
> <%@ Page Language="vb" AutoEventWireup="false"

Codebehind="WebForm1.aspx.vb"
> Inherits="test4.WebForm1"%>
> <%@ Register TagPrefix="uc1" TagName="uc" Src="uc.ascx" %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> <title>WebForm1</title>
> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
> <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
> <meta name="vs_defaultClientScript" content="JavaScript">
> <meta name="vs_targetSchema"
> content="http://schemas.microsoft.com/intellisense/ie5">
> </HEAD>
> <body MS_POSITIONING="GridLayout">
> <form id="Form1" method="post" runat="server">
>
> <uc1:uc id="Uc1" runat="server"></uc1:uc>
>
> </form>
> </body>
> </HTML>
> --------------------------------------------------------------------------

--
> -----------------------------
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the value of a Master page's control's property using a property of the Master page Nathan Sokalski ASP .Net 25 03-04-2010 03:42 AM
user control set property of a parent web form? jamesd ASP .Net 2 08-15-2006 04:07 PM
How do I set the property for a Web User Control properties from the parent form (VB) David Webb ASP .Net Web Controls 6 12-30-2004 09:21 PM
Error Setting user control property at web form Amir Eshterayeh ASP .Net Web Controls 1 11-27-2003 06:41 AM
Error Setting user control property at web form Amir Eshterayeh ASP .Net 0 11-27-2003 12:30 AM



Advertisments