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,116 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 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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 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