aspx 页面与ascx用户控件传值的问题

//****ascx用户控件中,定义一个要接收参数的属性
public partial class front_search : System.Web.UI.UserControl
{
    private int m_nFirstSortID; // 一级分类的ID,用于aspx传值进来
    public int FirstSortID
    {
        get { return m_nFirstSortID; }
        set { m_nFirstSortID = value; }
    }

    private int m_nSecondSortID; // 二级分类的ID
    public int SecondSortID
    {
        get { return m_nSecondSortID; }
        set { m_nSecondSortID = value; }
    }

}

 

// aspx页面,定义ascx的地方

<%@ Register TagPrefix="MySearch" TagName="Search" Src="~/front_search.ascx" %>

<td align="left">
 <MySearch:Search runat="server" ID="Search1" />
</td>

 

// 进行传值

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int nFirstSortID = RequestUtil.GetInt(Request, "first_sort_id", 0);
            int nSecondSortID = RequestUtil.GetInt(Request, "second_sort_id", 0);

            Search1.FirstSortID = nFirstSortID;
            Search1.SecondSortID = nSecondSortID;
        }
    }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值