UserCtrl1.Color = "green"行报错??

解决方案 »

  1.   

    只是说“生成项目时出错,仍要继续浏览吗?”,而且出来的内容color属性未修改。如果将"UserCtrl1.Color = "green""注释掉,则不报错!!!什么原因?谢谢!!!
      

  2.   

    颜色表达用System.Drawing.Color.Green
      

  3.   

    提示我UserCtrl1未声明。
    在什么地方声明呢?
      

  4.   

    <%@ Register TagPrefix="asp101samps" TagName="SomeText" src="WebForm4.aspx.vb" %>在aspx的顶端.
      

  5.   

    声明一个模块级变量:
    Protected WithEvents UserCtrl1 As UserControl1
    'UserControl1是你的用户控件的类名。
      

  6.   

    我的用户控件写在properties.ascx,其properties.ascx.vb内第一句是
    Public MustInherit Class properties
    properties是不是就是我的控件类名。可我在WebForm4.aspx.vb里声明了
    Protected WithEvents UserCtrl1 As properties提示我“Color不是WebApplication1.properties的成员”!这是为什么???谢谢!!!
      

  7.   

    试试这样:
    UserControl1 uc=(UserControl1)FindControl("uc");
    uc.Color = Color.Green;
      

  8.   

    properties.ascx.vb里面定义了Color这个属性吗?
      

  9.   

    在properties.ascx里定义的。<%@ Control Language="vb" AutoEventWireup="false" Codebehind="properties.ascx.vb" Inherits="WebApplication1.properties" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
    <script language="VB" runat="server">
    Public Color As String ="black"
    Public Text As String = "This is a user control...really!"
    </script>
    <P>
    <font color="<%= Color %>">
    <%=text%>
    </font>
    </P>
      

  10.   

    你要转换一下才可以用。
    dim oUCtrl as 控件所属的class =ctype(UserCtrl1 ,控件所属的class )以后你就可以用oUCtrl了。
      

  11.   

    我的意思是:我在*.aspx里有
    <form  method="post" runat="server">
         Qty:<asp:TextBox ID ="Qty" Runat="server"/>
    </form>
    如果我要在*.aspx.vb里引用要先定义
    Protected qty As TextBox那如果我要引用一个用户控件该如何写呢?
    用户控件如下:
    <%@ Control Language="vb" AutoEventWireup="false" Codebehind="properties.ascx.vb" Inherits="WebApplication1.properties" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %><script language="VB" runat="server">
    Public Color As String ="black"
    Public Text As String = "This is a user control...really!"
    </script>
    <P>
    <font color="<%= Color %>">
    <%=text%>
    </font>
    </P>
      

  12.   

    你既然使用了codebehide,你就应该把字段的定义放到properties.ascx.vb中,试试吧。