Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Trying to use "Visual Studio Templates", getting error View modes: 
User avatar
Member
Member
eagleag-yahoo - 4/12/2009 4:59:00 AM
   
Trying to use "Visual Studio Templates", getting error
HI,
Just downloaded "Visual Studio Templates"
http://devnet.kentico.com/Marketplace/Visual-Studio/Visual-Studio-Templates.aspx
I created my webpart and did everything needed.
Am getting an error:

[Error loading the WebPart '4hGallery']
c:\inetpub\wwwroot\KenticoCMS\CMSWebParts\4hImageGallery.ascx.cs(26): error CS0117: 'System.Web.UI.HtmlControls.HtmlImage' does not contain a definition for 'Text'


I used a LABEL in ASCX file and code behind looks like this:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.UI;



using CMS.CMSHelper;
using CMS.GlobalHelper;
using CMS.PortalControls;

public partial class CMSWebParts_4hImageGallery : CMSAbstractWebPart
{
#region "Properties"

/// <summary>
/// Gets or sets value of MyProperty
/// </summary>
public string MyProperty
{
get
{

img1.Text = (string)PartInstance.GetValue("img1");
img2.Text = (string)PartInstance.GetValue("img2");
img3.Text = (string)PartInstance.GetValue("img3");
img4.Text = (string)PartInstance.GetValue("img4");
return ValidationHelper.GetString(this.GetValue("MyProperty"), "");
}
set
{
this.SetValue("MyProperty", value);
}
}

#endregion


#region "Methods"

/// <summary>
/// Content loaded event handler
/// </summary>
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
}


/// <summary>
/// Initializes the control properties
/// </summary>
protected void SetupControl()
{
if (this.StopProcessing)
{
// Do nothing
}
else
{
// Set WebPart properties
// this.MyControl.MyProperty = this.MyProperty;
}
}


/// <summary>
/// Reload data
/// </summary>
public override void ReloadData()
{
base.ReloadData();

// Reload data in all controls if needed
// this.MyControl.ReloadData();
}

#endregion
}



How can I get the "Test" to work? (the label)

Many thanks and happy holidays :_


User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 4/16/2009 6:01:22 AM
   
RE:Trying to use "Visual Studio Templates", getting error
Hi,

it seems your code contains images – img1, img2, img3, img4 of System.Web.UI.HtmlControls.HtmlImage class. This class does not contain the Text property - http://www.w3schools.com/aspnet/control_htmlimage.asp

This causes the problem. You should use a different property instead of Text in e.g. img1.Text

Best regards,
Helena Grulichova