1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Exposing Child Controls as Properties of Sitefinity Control

Exposing Child Controls as Properties of Sitefinity Control

11 posts, 0 answered
  1. Rohit
    Rohit avatar
    11 posts
    Registered:
    06 Jan 2011
    20 Jul 2011
    Link to this post

    Hello Team,

    We have a problem here in exposing label property to the user to make change in that as you did in  http://www.sitefinity.com/help/developer-manual/controls-adding-controls-complex-child-controls.html .
    we want to show all the property of the label so the back end user can change any thing to our user control.
    every time when i try to see the edit property of the usercontrol it gives me error "object does not match target type".
    I pasted the code of usercontrol that's where  I get the error "object does not match target type" for which i want to expose property for all the controls in my user control below. Please help me in this. i am using the trial version of sitefinity 4.1

    //.ascx Code

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="bottemnetcall1.ascx.cs" Inherits="SitefinityWebApp.bottemnetcall1" %>
    </script>
    <div style="padding-left: 3px; padding-top: 3px; padding-bottom: 3px; padding-right: 3px;
        border: 1px solid #7893CA; width: 350px;">
        <table cellspacing="0" cellpadding="0" width="350px" border="0">
            <tr>
                <td width="50%" valign="top">
                    <div align="left">
                        <table align="left" id="Table1" style="border: 1px solid #A6CAF0; background-color: #A9D0F5;"
                            cellspacing="0" cellpadding="0" width="100%" runat="server">
                            <tr>
                                <td align="center" colspan="3" style="text-align: center; height: 15px; font-family: Verdana;
                                    font-size: 11px;">
                                    <b><asp:Label runat = "server" ID  = "lblHeader" Text = "Account Login for Registered User"></asp:Label></b>
                                </td>
                            </tr>
                            <tr>
                                <td align="left" style="text-align: center; font-family: Verdana; font-size: 11px;">
                                    <p align="left">
                                        <b><asp:Label  ID = "lblEmail" runat = "server" Text = "Email"></asp:Label></b></p>
                                </td>
                                <td align="left" valign="top" nowrap="nowrap" width="53%">
                                    <asp:TextBox ID="Username" runat="server" Width="229px" Font-Names="verdana" Font-Size="11px"></asp:TextBox>
                                    &nbsp;<asp:RequiredFieldValidator ID="Requiredfieldvalidator1" runat="server" ControlToValidate="Username"
                                        Display="Dynamic" ErrorMessage="Email-ID Required" ForeColor="red">*</asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator ID="REVEmailid" runat="server" ControlToValidate="Username"
                                        ErrorMessage="Invalid : Email Id " ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                        Display="Dynamic" ForeColor="red">*</asp:RegularExpressionValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="left" style="text-align: center; font-family: Verdana; font-size: 11px;">
                                    <p align="left">
                                        <b><asp:Label ID  = "lblPswd" runat = "server" Text = "Password"></asp:Label>&nbsp;&nbsp; </b>
                                    </p>
                                </td>
                                <td align="left" valign="top" width="53%" height="23">
                                    <asp:TextBox ID="UserPassword" runat="server" TextMode="Password" Width="229px" Font-Names="verdana"
                                        Font-Size="11px"></asp:TextBox>
                                    &nbsp;<asp:RequiredFieldValidator ID="Requiredfieldvalidator2" runat="server" ControlToValidate="Userpassword"
                                        Display="Dynamic" ErrorMessage="Password Required" ForeColor="red">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="left" colspan="2">
                                    &nbsp;&nbsp;
                                    <asp:CheckBox ID="chkAgreeTerms" runat="server" Font-Names="verdana" Font-Size="11px" />
                                    &nbsp;&nbsp;
                                    <asp:HyperLink ID="hyperlink_agree_to_terms" runat="server" Font-Names="verdana"
                                        Font-Size="11px">I agree to the Terms
                                        of Use</asp:HyperLink>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="3" style="height: 26px">
                                    <asp:Button ID="btnLogin" runat="server"  Style="width: 90" type="submit" Text = "Login"
                                        OnClick="btnLogin_Click" Font-Names="verdana" Font-Size="11px" />
                                    <%--<input id="btnSubmit" style="width: 90" type="submit" value="Login" name="btnSubmit"
                                    runat="server" onclick="return btnSubmit_onclick()" />--%>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="3">
                                    <asp:Label ID="Msg" runat="server" ForeColor="red" Font-Name="Verdana" Font-Size="10"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align="left" colspan="3">
                                    <asp:ValidationSummary ID="txtSummary" HeaderText="Check the following List" DisplayMode="BulletList"
                                        runat="server" ForeColor="Red" Font-Names="verdana" Font-Size="11px" />
                                </td>
                            </tr>
                            <tr>
                                <td align="left" colspan="3" style="text-align: center; font-family: Verdana; font-size: 11px;">
                                <b><asp:LinkButton ID = "Lnkforgotpswd" runat = "server"  Font-Size="11px"
                                        Font-Underline="false" onclick="Lnkforgotpswd_Click" Text = "Forgotten your login information?"></asp:LinkButton> </b>
                                   <%-- <b><a href="forgotmypassword" target="_top" >Forgotten your login information?</a></b>--%>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" class="Table_Data" colspan="3" height="19">
                                    <asp:LinkButton ID="lnkRegister" runat="server" Font-Names="verdana" Font-Size="11px"
                                        Font-Underline="true" OnClick="lnkRegister_Click" CausesValidation="false" Text = "New User Registration"></asp:LinkButton>&nbsp;&nbsp;&nbsp;<asp:LinkButton
                                            ID="lnkUnRegister" runat="server" OnClick="lnkUnRegister_Click" Font-Names="verdana" Text = "Cancel Registration"
                                            Font-Size="11px" Font-Underline="true" CausesValidation="false"></asp:LinkButton>
                                </td>
                            </tr>
                            <tr>
                                <td align="left" class="Table_Data" colspan="3" height="5">
                                </td>
                            </tr>
                        </table>
                    </div>
                </td>
            </tr>
        </table>
    </div>

     

    // .ascx code ends...........................

    //.ascx.cs code..................................

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Configuration;
    using System.ComponentModel;

    namespace SitefinityWebApp
    {
        [DefaultProperty("ControlTitle")]
        public partial class bottemnetcall1 : System.Web.UI.UserControl
        {

            string controlTitle = "Account Login for Registered User";

            [Category("List settings")]
            public string ControlTitle
            {
                get
                {
                  
                    return controlTitle;
                }
                set
                {
                    controlTitle = value;
                }

            }
            [Category("List settings")]
            public Label LabelHeader
            {
                get { return lblHeader; }
                set { lblHeader = value; }
            }

     

            //public lblHeader LabelHeader
            //{
            //    get { return lblHeader; }
            //}

           

            protected void Page_Load(object sender, EventArgs e)
            {

            }
           

            protected void btnLogin_Click(object sender, EventArgs e)
            {
            }

            protected void lnkRegister_Click(object sender, EventArgs e)
            {
            }

            protected void lnkUnRegister_Click(object sender, EventArgs e)
            {
            }

            protected void Lnkforgotpswd_Click(object sender, EventArgs e)
            {
            }

        }
    }

    //.ascx.cs code ends

  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    21 Jul 2011
    Link to this post
    Hi Rohit,

    The documentation you refer to is Sitefinity 3.x documentation and the approach is different there. Please refer to Sitefinity 4 documentation. Please refer to the code below to access the property.
    public partial class ClientControl : System.Web.UI.UserControl
        {
     
            string controlTitle = "Account Login for Registered User";
             
     
            [Category("List settings")]
            public string ControlTitle
            {
                get
                {
     
                    return controlTitle;
                }
                set
                {
                    controlTitle = value;
                }
     
            }
            [Category("List settings")]
            public String LabelHeaderText
            {
                get { return lblHeaderText; }
                set { lblHeaderText = value; }
            }
     
            private string lblHeaderText;
      
            protected void Page_Load(object sender, EventArgs e)
            {
                this.lblHeader.Text = this.LabelHeaderText;
            }
     
            protected void btnLogin_Click(object sender, EventArgs e)
            {
            }
     
            protected void lnkRegister_Click(object sender, EventArgs e)
            {
            }
     
            protected void lnkUnRegister_Click(object sender, EventArgs e)
            {
            }
     
            protected void Lnkforgotpswd_Click(object sender, EventArgs e)
            {
            }
        }


    Best wishes,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Rohit
    Rohit avatar
    11 posts
    Registered:
    06 Jan 2011
    22 Jul 2011
    Link to this post

    Hello Stan,

    This will be a nightmare for us. We want to expose every property of the "label" control (that is inside our user control) to the end users.

     

    So, if a label has 100 properties - then we have to write code to implement each and every property of the label.

     

    and if there are 50 individual controls inside our one user control and each control has 100 properties - then we have 50 * 100 = 5000 properties in 4.1

     

    Whereas in 3.x, we only had to write 50 properties (one for each individual control).

     

    50 in 3.x and 5000 in 4.1 --> This seems like a "downgrade" for us in 4.1 and not "upgrade" from 3.x.

     

    I am not sure how your various users in 3.x did not scream or complain about this big and bad change!

     

    We really need some kind of workaround or any possible way - to get the same behavior as that 3.x in 4.1 for this issue.

     

    Please help - else Sitefinity 4.1 will be something we have to stay away from.

     

    Thanks,

    Rohit

  4. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    25 Jul 2011
    Link to this post
    Hi Rohit,

    We discussed the problem with our developers and we are to change the approach used to expose label properties. We are going to modify it as in Sitefinity 3.x and you will be able to use all your controls in Sitefinity 4 without modifications. We are going to do it for the Q2 release in August. I would like to ask you to supply us with your controls if this is ok so we can test the new implementation with them?

    Greetings,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Rohit
    Rohit avatar
    11 posts
    Registered:
    06 Jan 2011
    25 Jul 2011
    Link to this post

    Stan,

    1)      Ok, great. This will be a welcome and very important change for us. Just to clarify another thing with you – The “label” that we mentioned here is just an example. We really want to expose the properties of “any” control such as label, TextBox, button, tabStrip or any RadControl for that matter. I assume that the change in approach that you mentioned here is not just for label but for any control – right?. Please clarify.

    2)      As requested by you, I have attached our user controls for you to test with. As you may see in the user controls, we have a mix of controls inside our user control and we require the properties to be exposed for each and every control inside it.

    3)    Since only image files are allowed, I have asked Ganesh to create a support ticket for you that contains the ZIP file of some samples of our user controls. The support ticket ID that he has created is 447000

     

    Please clarify on item 1) above.

     

    Thanks,

    Rohit

  6. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    25 Jul 2011
    Link to this post
    Hi Rohit,

    We intend to fix it all to be like it was so I don`t think the control type will be an issue here. I thank you for providing us with the controls for test.

    Best wishes,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    29 Jul 2011
    Link to this post
    Hi Rohit,

    We have spent quite a lot of time working on this, but we hit a rock and we won’t be able to do this for 4.2. Please accept my apologies.

    Namely, the problem is not in the persisting the properties, but rather in the display. In order for the child control property to be set, the control needs to enter the page lifecycle, as otherwise the control will be null. With the new Virtual Path Provider implementation this is not possible.

    As a workaround, I can suggest exposing properties that are needed as standard properties and mapping them to the controls in the PageLoad event.

    All the best,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Ganesh
    Ganesh avatar
    4 posts
    Registered:
    28 Jul 2006
    30 Jul 2011
    Link to this post
    Stan:
    Are you saying that this not possible in 4.2 or it is not possible in any of the 4.x versions because of the 4.x architecture?
    This is very important for us and our choice of Sitefinity CMS is based on your answer, and we need to decide it one way or the other.

    And by the way, your workaround of creating "standard" properties is not a workaround at all. That is too much work for us and will take several decades for us to implement the standard properties for the volume of controls that we have.

    Please let me know.

    Thanks,
    Ganesh
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    01 Aug 2011
    Link to this post
    Hello Ganesh,

    You need to create a control designer and expose the complex properties there.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Ganesh
    Ganesh avatar
    4 posts
    Registered:
    28 Jul 2006
    01 Aug 2011
    Link to this post
    Ivan:
    Thank you for your reply. I wish your reply had some links to any documentation or some samples. Anyways, I found this link below from your 4.1 documentation
    http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-controls-working-with-control-designers-multi-view-control-designers-creating-the-designer.html

    but I have a question on whether the link above or the approach that you have in mind will work for user controls as well?

    Please do note that we have 100% user controls that are a combination of multiple individual controls (as explained in this thread earlier) so I am not sure if your recommended approach will work for user controls as well?

    Please provide any samples/documentation that will work for our scenario and please treat this as "critical".

    Thanks,
    Ganesh
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    01 Aug 2011
    Link to this post
    Hi Ganesh,

    Yes, this article shows how to create control designer. Inside the template of the designer you can put the reference to the other user controls you have. You can download our SDK where you will find samples about how to create control and designer for it.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
11 posts, 0 answered