Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

DevExpress code doesn't work

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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