?
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,117 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 Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

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
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

752 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