简体   繁体   中英

Display label in custom control used on an ASP.Net aspx page?

I am using a Custom control in my aspx page. This custom control has a error message label. I need to display this label from the code behind on button click. How can i achieve this.

Button and custom control is in Update panel.

I assume that in the custom control you have the label you want to show and the button you have on the update panel outside the custom control.

If so, you should create a public method in your Custom control, something like public void ShowError(string message) and when you do the button click you call this method passing the text to display. In the method implementation inside the custom control you will assign the message text to the label and display the label if not visible. This should actually work either you use an update panel or not as long as both button and custom control are at the same time outside or inside the UpdatePanel but not one in and the other out.

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