简体   繁体   中英

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.

So the user control looks like this in my aspx page;

<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.

I know I can use LoadControl but is there a way I can pass a C# variable to my user control?

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

bookId=<%# book.BookId %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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