Solved

DevExpress code doesn't work

Posted on 2011-02-24
3
694 Views
Last Modified: 2012-05-11
I have the following code that works in a ASPxGridViewDemo but doesn't work when I copied it to a separate solution in VS 2010:

It says that for the hlItem "The name 'hlItem' does not exist in the current contex".

What's wrong?

using System;
using System.Web.UI;
using System.ComponentModel;
using DevExpress.Web.ASPxHeadline;

public partial class DemoNavBarItemTemplate : UserControl {
    private static readonly object EventHeadlineDataBinding = new object();
    private bool isSelected;

    public string ContentText {
        get { return hlItem.ContentText; }
        set { hlItem.ContentText = value; }
    }
    public string NavigateUrl {
        get { return hlItem.NavigateUrl; }
        set { hlItem.NavigateUrl = value; }
    }
    public bool IsSelected {
        get { return isSelected; }
        set { isSelected = value; }
    }

    // Events
    [Category("Action")]
    public event EventHandler HeadlineDataBinding {
        add { Events.AddHandler(EventHeadlineDataBinding, value); }
        remove { Events.RemoveHandler(EventHeadlineDataBinding, value); }
    }

    protected override void OnDataBinding(EventArgs e) {
        base.OnDataBinding(e);
        RaiseHeadlineDataBinding();
        if(IsSelected)
            hlItem.NavigateUrl = "";
    }
    protected void RaiseHeadlineDataBinding() {
        EventArgs args = new EventArgs();
        OnHeadlineDataBinding(args);
    }
    protected void OnHeadlineDataBinding(EventArgs e) {
        EventHandler handler = Events[EventHeadlineDataBinding] as EventHandler;
        if(handler != null)
            handler(hlItem, e);
    }
}
   

Open in new window


0
Comment
Question by:DistillingExperts
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
robasta earned 500 total points
ID: 34968476
-make sure the controls are on the aspx form, then
-in the other solution, right click the file and select 'Convert to web Application' after copying the code.

0
 

Author Comment

by:DistillingExperts
ID: 34968602
Hi Robasta,

Thanks a lot. It worked. Why do I have to convert to web application? In the demo it doesn't seem to be converted.
0
 
LVL 14

Expert Comment

by:robasta
ID: 34968830
'Convert to web app' does some 'magic' in the background. Im not exactly sure what it does but I know that it synchronizes the page.aspx with the page.aspx.designer.cs
If the two files are not in 'sync' thats when you get that error.

so when you get that error, it i usually because you copy a control to the aspx page, but then the designer file does not have the declaration for that control and therefore the control is not accessible in the code behind.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now