index.aspx文件如下<%@ Register TagPrefix="header" TagName="top" src="top.ascx"%>
<%@ Page Language="vb" AutoEventWireup="false"  Inherits="vod.index"  Codebehind="index.aspx.vb"%>
<header:top id="top1" runat="server"  />top.ascx文件如下
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="top.ascx.vb" Inherits="vod.top" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<tr>
<td vAlign="top" height="12"><IMG height="24" src="images/top10.gif" width="197"></td>
</tr>
<tr>
<td vAlign="top">
<table cellSpacing="0" cellPadding="2" width="95%" align="center" border="0">
<tr>
<td colSpan="2" height="13">
<asp:DataGrid id="DataGrid1" runat="server" BorderWidth="0" AutoGenerateColumns="false" Width="95%"
HorizontalAlign="Center" CellPadding="2" CellSpacing="0">
<Columns>
<asp:BoundColumn HeaderText="名次" DataField="IntegerValue" ItemStyle-Width="20" ItemStyle-CssClass="b8"
ItemStyle-VerticalAlign="Middle" ItemStyle-ForeColor="#ffcc00" ItemStyle-Font-Size="9" />
<asp:HyperLinkColumn HeaderText="电影名称" DataNavigateUrlField="IntegerValueUrl" DataNavigateUrlFormatString="movie.aspx?id={0}"
DataTextField="StringValue" ItemStyle-ForeColor="#ffffff" />
</Columns>
</asp:DataGrid></td>
</tr>
</table>
</td>
</tr>
我想把index.aspx.vb里的值传递到top.ascx.vb,应该如何做?
如何在<header:top id="top1" runat="server"  />里加属性传到top.ascx.vb里?
比如说:<header:top id="top1" runat="server" TestValue="123" /> 
我应该如何在top.ascx.vb定义,并接收它?

解决方案 »

  1.   

    利用属性传值。MSDN有个这样的例子找找看。
      

  2.   

    ascx:
    public string TestValue
      

  3.   

    楼上都是开玩笑的。要到top.aspx需要在index.aspx中Response.Redirect
      

  4.   

    在top.ascx.vb里加入下面代码
        Public writeonly Property testvalue() As String
            Set(ByVal Value As String)
                TextBox1.Text= Value  '当然也可以把属性值传给别的控件
            End Set
        End Property
      

  5.   

    1. in top.ascx.vb namespace vodpublic class top
     private ms as String = String.Empty
    public Property TestValue() As String
     get
       return ms
      end get
     Set(ByVal Value As String)
       ms = Value
     end
    end property2. in index.aspx.vbnamespace vodpublic class index 
      protected top1 as top           'top1 is the id in your aspx page  sub page_Load()
           top1.TestValue = "abc"
      end sub