User Control Properties

Posted by Community Admin on 03-Aug-2018 18:59

User Control Properties

All Replies

Posted by Community Admin on 25-Nov-2010 00:00

Hi,

I've made a simple user control with some public properties, the c# code inside a script server tag. I copied this .ascx file into a Controls folder in my web application. I registered the control under Administration -> Settings -> Advance -> Toolboxes ....  so the control displays well on the toolbox. I add it to my page but I dont have access to its public properties when I click "Edit". Documentation says that SiteFinity will automatically generate a Property Grid editor for all the public properties. Where ? How ? I don't know if I'm missing something.

I would appreciate any help to continue my evaluation process.

Thanks,

Posted by Community Admin on 25-Nov-2010 00:00

Hi John,

Create a code behind file of your ascx and put the properties there or use a class library.

All the best,
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

Posted by Community Admin on 25-Nov-2010 00:00

Thanks for your reply.
 
I did it with a code behind file, with and without dll copied in sitefinity bin folder and it doesn't work either. Properties are not available.

I've got to say that I'm using VS 2008 to make a simple user control and then to copy it in my SF 4.0 RC application. Is it correct this way ?

Regards, 

Posted by Community Admin on 25-Nov-2010 00:00

Hi John,

Below is a sample control that you can use

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="SitefinityWebApp.Controls.WebUserControl1" %>
 
 
<asp:Literal runat="server" ID="Literal1"></asp:Literal>
<asp:TextBox runat="server" ID="TextBox1"></asp:TextBox>
<asp:HyperLink runat="server" ID="HyperLink1"></asp:HyperLink>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace SitefinityWebApp.Controls
    public partial class WebUserControl1 : System.Web.UI.UserControl
    
        protected void Page_Load(object sender, EventArgs e)
        
            Literal1.Text = Title;
            TextBox1.Text = Body;
            HyperLink1.Text = LinkText;
            HyperLink1.NavigateUrl = LinkUrl;
        
 
        public string Title
        
            get return this._title;
            set this._title = value;
        
        public string Body
        
            get return this._body;
            set this._body = value;
        
        public string LinkText
        
            get return this._linktext;
            set this._linktext = value;
        
        public string LinkUrl
        
            get return this._linkurl;
            set this._linkurl = value;
        
 
        private string _title;
        private string _body;
        private string _linktext;
        private string _linkurl;
    


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

This thread is closed