Solved

DevExpress code doesn't work

Posted on 2011-02-24
3
699 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
[X]
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
  • 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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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 …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

710 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