开发者

ASP.NET UI Control as property in interface

开发者 https://www.devze.com 2023-03-24 19:27 出处:网络
I have a number of pages which implement the same interface: Public Interface myPage Sub doSomething() Sub doSomethingToTextBox(ByVal textB开发者_如何学Pythonox As TextBox)

I have a number of pages which implement the same interface:

Public Interface myPage

    Sub doSomething()
    Sub doSomethingToTextBox(ByVal textB开发者_如何学Pythonox As TextBox)

End Interface

The function doSomethingToTextBox takes a textBox item as a parameter and performs some action on it.

I know the textBox is contained on every page which implements my interface, and that it has the same name on each page.

My question is: how can I declare the textBox as an interface property? This will remove the need to pass the textBox as a parameter to doSomethingToTextBox()

I must also add that I'm currently accessing the TextBox using get/set methods defined as part of the interface - I don't want to have to implement these methods for each page as they are exactly the same on each page.


using System.Web.UI.WebControls;
interface IMyPage
    {
        TextBox myTextBox{get; set;}
    }

and in the page you have to make a property to return the protected textbox in the page but i can't see how you will use that ?!

0

精彩评论

暂无评论...
验证码 换一张
取 消