Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DevExpress code doesn't work

Posted on 2011-02-24
3
Medium Priority
?
702 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Integration Management Part 2
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

916 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