Passing public properties to destination page

S

ssp

Hi All,

I have this search user control (search.ascx) which is completely self
contained i.e. it has a button which leads to the results.aspx page.

The problem is one of, the destination page being unable to access the
public properties of the user control which becomes part of another web
form of course.

I hope I am making sense.

Anyway my question is; what happens to the public properties of the
user control when it is added to a web form? Can the destination page
access them?

SSP
 
A

Anmol

Hi You need to declare the variable with the Control name in the
destination page.
From that variable you can set/get all the public properties of that
control.
for ex the class name of WebControl is MyControl and this control is
added in the Destination page by the ID of MyControl1, To use this
object in code behind u need to add these lines:-

protected MyControl MyControl1;

Now you can set all the public properties of this control

Alternatively you can set these property in the design view.

<uc1:MyControl id="MyControl1" MyPublicPropertyName="New Property
Value" runat="server"></uc1:MyControl >

Here MyPublicPropertyName is the public property of the control and New
Property Value is the value assigned to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top