简体   繁体   English

Web用户控件属性

[英]Web User Control Properties

I know this is somewhat of a beginner question but I can't remember how to do this. 我知道这有点是初学者的问题,但我不记得该怎么做。

I have a web user control and it inherits from an interface with a single property. 我有一个Web用户控件,它从具有单个属性的接口继承。

So the user control looks like this in my aspx page; 因此,用户控件在我的aspx页面中看起来像这样;

<uc1:PublishPricingCalculator ID="PublishPricingCalculator" runat="server" bookId='<%=book.BookId %>' />

In my code behind I have this; 在我后面的代码中,我有这个;

    [BrowsableAttribute(true)]
    public string bookId { get; set; }

However, when I inspect the value being passed from the UI i see '<%=book.BookId %>' instead of my GUID. 但是,当我检查从UI传递的值时,我看到的是'<%=book.BookId %>'而不是我的GUID。

I know I can use LoadControl but is there a way I can pass a C# variable to my user control? 我知道我可以使用LoadControl,但是有什么方法可以将C#变量传递给用户控件?

是的,但是您需要使用其他语法:

bookId=<%# book.BookId %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM