简体   繁体   English

公开方法作为用户控件中的属性

[英]Expose method as a property in user control

I created user control for textbox with autocompleteextender, and its working fine, but now i wanted to expose methods in user control to aspx page as a one of the property in user control,like in button control having onClientClick event. 我使用autocompleteextender为文本框创建了用户控件,并且它可以正常工作,但是现在我想将用户控件中的方法作为用户控件中的属性之一公开给aspx页面,例如具有onClientClick事件的按钮控件。 and forgive my English. 并原谅我的英语

Try adding a property like this to your user control: 尝试将这样的属性添加到用户控件中:

public string OnClientClick
{
    get { return Button1.OnClientClick; }
    set
    {
        Button1.OnClientClick = value;
    }
}

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

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