Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

c# add double click serverside event to asp:listbox, i have half of code, just need to fill gaps

Posted on 2011-02-21
4
Medium Priority
?
1,120 Views
Last Modified: 2012-05-11
hi all,

im tryign to add a double click event to an asp:listbox, i found a forum post on google that had the code below on it, but didnt explain how to use it. ive hazarded a guess but am still getting errors

can anyone help me out?
Thanks

the InitializeComponent method ive had to comment out as, im getting InitializeComponent does not exist in the current context and ive googled that its not needed for web forms?

anyway the code below gives
EventHandler.Control.DoubleClick can only appear at  += etc error
ive tried
Listbox.Controls.Add.DoubleClick but that gives
ControlCollection.Add is a method which is not valid in the current given context

Thanks for any help
using System;
using System.Web;
using System.Windows.Forms;


public partial class Controls_ListBox : UserControl
{
/*
    public Controls_ListBox()
        {
            InitializeComponent();
        }
 */
        public event EventHandler MyServerClick;

        protected override void OnControlAdded(ControlEventArgs e)
        {
            base.OnControlAdded(e);
            e.Control.DoubleClick += new EventHandler(Control_DoubleClick);
        }
 
        protected override void OnControlRemoved(ControlEventArgs e)
        {
            e.Control.DoubleClick -= new EventHandler(Control_DoubleClick);
            base.OnControlRemoved(e);
        }
 
        void Control_DoubleClick(object sender, EventArgs e)
        {
            this.OnDoubleClick(e);
        }

    protected void Page_Load(object sender, EventArgs e)
    {
        Listbox.Controls.Add(DoubleClick) += new EventHandler(MyServerClick);

    }

}

Open in new window

0
Comment
Question by:awilderbeast
[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
4 Comments
 
LVL 16

Accepted Solution

by:
Kalpesh Chhatrala earned 1000 total points
ID: 34941566
0
 
LVL 1

Author Comment

by:awilderbeast
ID: 34942047
yeah i have another script in which ive used javascript to cause a button click, but i was hoping id be able to add the double click event serverside and not use java

can this not be done?

Thanks
0
 
LVL 20

Assisted Solution

by:informaniac
informaniac earned 1000 total points
ID: 34949097
frm server side u wud be able 2 add only those events tht r visible in the properties window event section. SelectedInde
0
 
LVL 1

Author Closing Comment

by:awilderbeast
ID: 34949456
thanks
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

636 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