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
1,113 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
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
Kalpesh Chhatrala earned 250 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 250 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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 …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

786 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