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

Forums / General Discussions / Can't edit user control properties

Can't edit user control properties

2 posts, 0 answered
  1. Doug Dawson
    Doug Dawson avatar
    21 posts
    Registered:
    18 Aug 2009
    10 Nov 2010
    Link to this post
    Hello!

    I have a ton of problems making user controls for Sitefinity. Here's the first issue I am having:

    I have a web user control with some public properties, but the properties are not editable when I add the control to a page.

    1.<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FeatureBanner.ascx.cs" %>
    2.<div runat="server" id="bannerContainer">
    3.    <asp:HyperLink ID="bannerLink" runat="server"><img id="bannerImage" runat="server" src="" alt="" title="" /></asp:HyperLink>
    4.    <p><span class="title"><asp:Literal runat="server" ID="bannerTitle" /></span><br /><asp:Literal runat="server" ID="bannerText" /></p>
    5.    <div style="clear:both;"></div>
    6.</div>

    Here's the code behind:

    01.using System;
    02.using System.Collections.Generic;
    03.using System.Web;
    04.using System.Web.UI;
    05.using System.Web.UI.WebControls;
    06. 
    07.public partial class FeatureBanner : System.Web.UI.UserControl
    08.{
    09.    private string _title;
    10.    private string _text;
    11.    private string _imgPath;
    12.    private string _linkPath;
    13.    private bool _transparent;
    14. 
    15.    public string Title
    16.    {
    17.        get { return _title; }
    18.        set { _title = value; }
    19.    }
    20. 
    21.    public string Text
    22.    {
    23.        get { return _text; }
    24.        set { _text = value; }
    25.    }
    26. 
    27.    public string ImagePath
    28.    {
    29.        get { return _imgPath; }
    30.        set { _imgPath = value; }
    31.    }
    32.    public string LinkPath
    33.    {
    34.        get { return _linkPath; }
    35.        set { _linkPath = value; }
    36.    }
    37.    public bool IsTransparent
    38.    {
    39.        get { return _transparent; }
    40.        set { _transparent = value; }
    41.    }
    42. 
    43.    protected global::System.Web.UI.HtmlControls.HtmlGenericControl bannerContainer;
    44.    protected global::System.Web.UI.WebControls.HyperLink bannerLink;
    45.    protected global::System.Web.UI.HtmlControls.HtmlImage bannerImage;
    46.    protected global::System.Web.UI.WebControls.Literal bannerTitle;
    47.    protected global::System.Web.UI.WebControls.Literal bannerText;
    48. 
    49.    protected void Page_Load(object sender, EventArgs e)
    50.    {
    51.        if (this.IsTransparent)
    52.        {
    53.            bannerContainer.Attributes.Add("class", "actionbox transparent");
    54.        }
    55.        else
    56.        {
    57.            bannerContainer.Attributes.Add("class", "actionbox");
    58.        }
    59. 
    60.        bannerImage.Src = this.ImagePath;
    61.        bannerImage.Alt = this.Title;
    62.        bannerImage.Attributes.Add("title", this.Title);
    63.        bannerLink.NavigateUrl = this.LinkPath;
    64.        bannerText.Text = this.Text;
    65.        bannerTitle.Text = this.Title;
    66.    }
    67.}

    Seems pretty simple and straight forward, but it's not working. What am I missing? Thanks!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Nov 2010
    Link to this post
    Hi Doug,

    Remove the following lines from the code behind

    protected global::System.Web.UI.HtmlControls.HtmlGenericControl bannerContainer;
    protected global::System.Web.UI.WebControls.HyperLink bannerLink;
    protected global::System.Web.UI.HtmlControls.HtmlImage bannerImage;
    protected global::System.Web.UI.WebControls.Literal bannerTitle;
    protected global::System.Web.UI.WebControls.Literal bannerText;


    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered