Passing public properties to destination page

Discussion in 'ASP .Net Web Controls' started by ssp, Jun 8, 2006.

  1. ssp

    ssp Guest

    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
     
    ssp, Jun 8, 2006
    #1
    1. Advertising

  2. ssp

    Anmol Guest

    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.
     
    Anmol, Jun 8, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page