Solved

DevExpress code doesn't work

Posted on 2011-02-24
3
695 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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:…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

943 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

9 Experts available now in Live!

Get 1:1 Help Now