I have a method written in WebForm (means .aspx page) & now
I want to call this method in WebUserControl (means .ascx
page) what should I have to do?

Answer Posted / jp

Use the controls page property and typecast it to the page
class name.

eg:
Page Default.aspx has a control MyControl.ascx
Page Default.aspx.cs has a method MyMethod()

in MyControl.ascx.cs

((Default)(this.Page)).MyMethod();

Is This Answer Correct ?    7 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which method do you use to enforce garbage collection in .net?

512


How to register exception filter globally?

573


Can we use html in asp.net?

494


What are the best practices to follow to secure connection strings in an ASP.NET web application?

550


How does output caching work in ASP.NET?

495






To display data in a Repeater control which template you provide?

584


What happens if an ASP.NET server control with event-handling routines is missing from its definition?

595


Which validator control you use if you need to make sure the values in two different controls matched?

641


Explain about secure socket layer?

518


How dataadapter.fill works?

558


How can you make sure that web api returns json data only?

510


What is data binding in asp net?

581


What does the hotspot class in .net do?

561


What is the difference between WindowsDefaultLocation and WindowsDefaultBounds?

666


How to change Master page in ASP.Net using code?

587