Re: CompositeControl fails to display in Design view
- From: MC <mc@xxxxxxxxxxxxxxxx>
- Date: Thu, 11 Oct 2007 15:59:11 GMT
apologies, should have read your description in more detail
Philvb wrote:
Hi MC,.
Yes, if you follow the instructions then that is how you can debug the designer.
Phil
"MC" wrote:
I have no problem with the Custom Control, It works fine in the browser, It is the design time experience that is not working.
Can you debug the designer in Visual Studio?
Philvb wrote:Hi MC,
the message you are getting here is from your logic in the rendering of the control at a guess i'd say that an object hasn't been instanciated.
But here's how i debug ALL my custom controls in real time.
In Order to debug a Custom Control you need to Start ANOTHER copy of Visual Studio along side your existing one,and pointing it to a test website.
This can be done by
Going To The Controls Project Properties and Selecting The Debug Tab then set the start action to `Start External Program` and set the box next to it to the location of devenv.exe from the correct folder of program files.
i am using orcas beta2 here and this path is: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe
Now set the Command Line Arguments to: /Command File.OpenWebsite TheTestingWebSite.sln
Now The Final Step Is To Enter The FULL Path of Your SOLUTION FILE in the Working Directory text box.
Just press F5 to start your debugging Adventure...
hope this helps
Wbr
Phil
"MC" wrote:
I'm getting the following error messages when I view my ComposisteControl in design time mode.
"Error Rendering Control - <My Control Name>"
"An unhandled exception has occurred
Object reference not set to an instance of an object"
The Control is as follows: -
public class TrackedAd : CompositeControl
{
public SqlDataSource sdsAds = new SqlDataSource();
public System.Web.UI.WebControls.AdRotator adRot = new System.Web.UI.WebControls.AdRotator();
private string _Target = "_blank";
private int _SponsorId = -1;
[Description("The Browser Target for the Attribute"), TypeConverterAttribute(typeof(TargetConverter))]
public string Target
{
get { return _Target; }
set { _Target = value; }
}
public int SponsorId
{
get { return _SponsorId; }
set { _SponsorId = value; }
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Page.RegisterRequiresControlState(this);
}
protected override object SaveControlState()
{
object[] state = { base.SaveControlState(), _Target, _SponsorId };
return state;
}
protected override void LoadControlState(object state)
{
if (state != null)
{
object[] stateTmp = (object[])state;
base.LoadControlState(stateTmp[0]);
_Target = (string)stateTmp[1];
_SponsorId = (int)stateTmp[2];
}
}
protected override void CreateChildControls()
{
sdsAds.ConnectionString = ConfigurationManager.ConnectionStrings["RedsSponsors"].ConnectionString;
sdsAds.ProviderName = ConfigurationManager.ConnectionStrings["RedsSponsors"].ProviderName;
sdsAds.SelectCommand = string.Format("SELECT '{0}'+iif(ImageName<>null,ImageName,'../transp.gif') AS ImageUrl, CompanyName AS AlternateText, URL AS NavigateUrl, Impressions, Clicks FROM Sponsors WHERE Id={1}", Utils.SponsorsImageBase, SponsorId);
sdsAds.ID = "sdsAds";
adRot.AdCreated += new AdCreatedEventHandler(this_AdCreated);
adRot.DataSourceID = "sdsAds";
adRot.Target = Target;
Controls.Add(sdsAds);
Controls.Add(adRot);
}
protected void this_AdCreated(object sender, AdCreatedEventArgs e)
{
SponsorsUtils.IncrementAdvertStat("CompanyName", "Impressions", e.AlternateText);
if (e.NavigateUrl != "")
{
e.NavigateUrl = string.Format("~/Adverts/AdvertHandler.ashx?Url={0}", Page.Server.UrlEncode(e.NavigateUrl));
}
}
}
What is wrong? I thought by using compositecontrol I would not have to worry about designtime?
- Follow-Ups:
- References:
- Prev by Date: Re: CompositeControl fails to display in Design view
- Next by Date: Re: CompositeControl fails to display in Design view
- Previous by thread: Re: CompositeControl fails to display in Design view
- Next by thread: Re: CompositeControl fails to display in Design view
- Index(es):
Relevant Pages
|