Re: event handling question

Discussion in 'ASP .Net' started by S. Justin Gengo, Aug 20, 2003.

  1. Will,

    That event is already defined for you.

    Take out the "OnSelectedIndexChanged" event from your control. That is the
    client side event. You want the server side one.

    Now set the list box's AutoPostBack property to "True".

    In your code behind page use this:

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles ListBox1.SelectedIndexChanged

    End Sub



    Sincerely,


    --
    S. Justin Gengo, MCP
    Web Developer


    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche


    "Will" <> wrote in message
    news:070f01c366ac$3004e0e0$...
    > I'm writing a control. One of the things this control does
    > is render three listboxes on the page. I populate one of
    > these boxes and leave the others empty. I include this
    > control in my asp.net page using a register directive and
    > placing a custom control tag where I want it to appear.
    >
    > The problem I am having is that when I select something in
    > the populated listbox I want to fire off an event. If I
    > put OnSelectedIndexChange="controlID.MyEventFunction" in
    > the tag everything complies fine, but nothing happens when
    > I select something in the listbox. how do I create an
    > event in my control and tie it to the event of selecting
    > something in the listbox?
    >
    > Details are most helpful, thank you
    S. Justin Gengo, Aug 20, 2003
    #1
    1. Advertising

  2. S. Justin Gengo

    Will Guest

    Thanks, I think that will work great.. I'm coding in C#
    though, how do I use that handles statement that way?
    Also, will this still work if I put it in my class
    definitions instead of in a code behind in the page?
    Thanks again


    Will



    >-----Original Message-----
    >Will,
    >
    >That event is already defined for you.
    >
    >Take out the "OnSelectedIndexChanged" event from your

    control. That is the
    >client side event. You want the server side one.
    >
    >Now set the list box's AutoPostBack property to "True".
    >
    >In your code behind page use this:
    >
    >Private Sub ListBox1_SelectedIndexChanged(ByVal sender As

    Object, ByVal e As
    >System.EventArgs) Handles ListBox1.SelectedIndexChanged
    >
    >End Sub
    >
    >
    >
    >Sincerely,
    >
    >
    >--
    >S. Justin Gengo, MCP
    >Web Developer
    >
    >
    >Free code library at:
    >www.aboutfortunate.com
    >
    >"Out of chaos comes order."
    > Nietzche
    >
    >
    >"Will" <> wrote in message
    >news:070f01c366ac$3004e0e0$...
    >> I'm writing a control. One of the things this control

    does
    >> is render three listboxes on the page. I populate one of
    >> these boxes and leave the others empty. I include this
    >> control in my asp.net page using a register directive

    and
    >> placing a custom control tag where I want it to appear.
    >>
    >> The problem I am having is that when I select something

    in
    >> the populated listbox I want to fire off an event. If I
    >> put OnSelectedIndexChange="controlID.MyEventFunction" in
    >> the tag everything complies fine, but nothing happens

    when
    >> I select something in the listbox. how do I create an
    >> event in my control and tie it to the event of selecting
    >> something in the listbox?
    >>
    >> Details are most helpful, thank you

    >
    >
    >.
    >
    Will, Aug 20, 2003
    #2
    1. Advertising

  3. Will,

    Sorry, I'm not certain about either. I think I could come up with the c#
    equivalent if I had to but maybe someone who knows c# better than I do (I'm
    just learning it) could show the proper formatting of this subroutine. I'm
    also not positive if this works exactly the same way if you don't use a
    codebehind page. I use codebehind for everything I do.

    Sincerely,

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche


    "Will" <> wrote in message
    news:08f801c366b8$6c73a640$...
    > Thanks, I think that will work great.. I'm coding in C#
    > though, how do I use that handles statement that way?
    > Also, will this still work if I put it in my class
    > definitions instead of in a code behind in the page?
    > Thanks again
    >
    >
    > Will
    >
    >
    >
    > >-----Original Message-----
    > >Will,
    > >
    > >That event is already defined for you.
    > >
    > >Take out the "OnSelectedIndexChanged" event from your

    > control. That is the
    > >client side event. You want the server side one.
    > >
    > >Now set the list box's AutoPostBack property to "True".
    > >
    > >In your code behind page use this:
    > >
    > >Private Sub ListBox1_SelectedIndexChanged(ByVal sender As

    > Object, ByVal e As
    > >System.EventArgs) Handles ListBox1.SelectedIndexChanged
    > >
    > >End Sub
    > >
    > >
    > >
    > >Sincerely,
    > >
    > >
    > >--
    > >S. Justin Gengo, MCP
    > >Web Developer
    > >
    > >
    > >Free code library at:
    > >www.aboutfortunate.com
    > >
    > >"Out of chaos comes order."
    > > Nietzche
    > >
    > >
    > >"Will" <> wrote in message
    > >news:070f01c366ac$3004e0e0$...
    > >> I'm writing a control. One of the things this control

    > does
    > >> is render three listboxes on the page. I populate one of
    > >> these boxes and leave the others empty. I include this
    > >> control in my asp.net page using a register directive

    > and
    > >> placing a custom control tag where I want it to appear.
    > >>
    > >> The problem I am having is that when I select something

    > in
    > >> the populated listbox I want to fire off an event. If I
    > >> put OnSelectedIndexChange="controlID.MyEventFunction" in
    > >> the tag everything complies fine, but nothing happens

    > when
    > >> I select something in the listbox. how do I create an
    > >> event in my control and tie it to the event of selecting
    > >> something in the listbox?
    > >>
    > >> Details are most helpful, thank you

    > >
    > >
    > >.
    > >
    S. Justin Gengo, Aug 20, 2003
    #3
  4. S. Justin Gengo

    rory Guest

    Yes this will work if it is defined within the page and
    not in codebehind. However, you may need to set
    the 'AutoEventWireup' directive to True. This will also
    saving you having to write code to attach to specific
    events (ie handles)



    >-----Original Message-----
    >Will,
    >
    >Sorry, I'm not certain about either. I think I could come

    up with the c#
    >equivalent if I had to but maybe someone who knows c#

    better than I do (I'm
    >just learning it) could show the proper formatting of

    this subroutine. I'm
    >also not positive if this works exactly the same way if

    you don't use a
    >codebehind page. I use codebehind for everything I do.
    >
    >Sincerely,
    >
    >--
    >S. Justin Gengo, MCP
    >Web Developer
    >
    >Free code library at:
    >www.aboutfortunate.com
    >
    >"Out of chaos comes order."
    > Nietzche
    >
    >
    >"Will" <> wrote in message
    >news:08f801c366b8$6c73a640$...
    >> Thanks, I think that will work great.. I'm coding in C#
    >> though, how do I use that handles statement that way?
    >> Also, will this still work if I put it in my class
    >> definitions instead of in a code behind in the page?
    >> Thanks again
    >>
    >>
    >> Will
    >>
    >>
    >>
    >> >-----Original Message-----
    >> >Will,
    >> >
    >> >That event is already defined for you.
    >> >
    >> >Take out the "OnSelectedIndexChanged" event from your

    >> control. That is the
    >> >client side event. You want the server side one.
    >> >
    >> >Now set the list box's AutoPostBack property to "True".
    >> >
    >> >In your code behind page use this:
    >> >
    >> >Private Sub ListBox1_SelectedIndexChanged(ByVal sender

    As
    >> Object, ByVal e As
    >> >System.EventArgs) Handles ListBox1.SelectedIndexChanged
    >> >
    >> >End Sub
    >> >
    >> >
    >> >
    >> >Sincerely,
    >> >
    >> >
    >> >--
    >> >S. Justin Gengo, MCP
    >> >Web Developer
    >> >
    >> >
    >> >Free code library at:
    >> >www.aboutfortunate.com
    >> >
    >> >"Out of chaos comes order."
    >> > Nietzche
    >> >
    >> >
    >> >"Will" <> wrote in message
    >> >news:070f01c366ac$3004e0e0$...
    >> >> I'm writing a control. One of the things this control

    >> does
    >> >> is render three listboxes on the page. I populate

    one of
    >> >> these boxes and leave the others empty. I include

    this
    >> >> control in my asp.net page using a register directive

    >> and
    >> >> placing a custom control tag where I want it to

    appear.
    >> >>
    >> >> The problem I am having is that when I select

    something
    >> in
    >> >> the populated listbox I want to fire off an event.

    If I
    >> >> put

    OnSelectedIndexChange="controlID.MyEventFunction" in
    >> >> the tag everything complies fine, but nothing happens

    >> when
    >> >> I select something in the listbox. how do I create an
    >> >> event in my control and tie it to the event of

    selecting
    >> >> something in the listbox?
    >> >>
    >> >> Details are most helpful, thank you
    >> >
    >> >
    >> >.
    >> >

    >
    >
    >.
    >
    rory, Aug 20, 2003
    #4
  5. S. Justin Gengo

    James Zhuo Guest

    The point about AutoEventWireup, and where is this attribute set?
    Is autoeventwireup something that is C# specific or is that also used with
    VB

    "rory" <> wrote in message
    news:0ae001c366d8$b6ebc660$...
    >
    > Yes this will work if it is defined within the page and
    > not in codebehind. However, you may need to set
    > the 'AutoEventWireup' directive to True. This will also
    > saving you having to write code to attach to specific
    > events (ie handles)
    >
    >
    >
    > >-----Original Message-----
    > >Will,
    > >
    > >Sorry, I'm not certain about either. I think I could come

    > up with the c#
    > >equivalent if I had to but maybe someone who knows c#

    > better than I do (I'm
    > >just learning it) could show the proper formatting of

    > this subroutine. I'm
    > >also not positive if this works exactly the same way if

    > you don't use a
    > >codebehind page. I use codebehind for everything I do.
    > >
    > >Sincerely,
    > >
    > >--
    > >S. Justin Gengo, MCP
    > >Web Developer
    > >
    > >Free code library at:
    > >www.aboutfortunate.com
    > >
    > >"Out of chaos comes order."
    > > Nietzche
    > >
    > >
    > >"Will" <> wrote in message
    > >news:08f801c366b8$6c73a640$...
    > >> Thanks, I think that will work great.. I'm coding in C#
    > >> though, how do I use that handles statement that way?
    > >> Also, will this still work if I put it in my class
    > >> definitions instead of in a code behind in the page?
    > >> Thanks again
    > >>
    > >>
    > >> Will
    > >>
    > >>
    > >>
    > >> >-----Original Message-----
    > >> >Will,
    > >> >
    > >> >That event is already defined for you.
    > >> >
    > >> >Take out the "OnSelectedIndexChanged" event from your
    > >> control. That is the
    > >> >client side event. You want the server side one.
    > >> >
    > >> >Now set the list box's AutoPostBack property to "True".
    > >> >
    > >> >In your code behind page use this:
    > >> >
    > >> >Private Sub ListBox1_SelectedIndexChanged(ByVal sender

    > As
    > >> Object, ByVal e As
    > >> >System.EventArgs) Handles ListBox1.SelectedIndexChanged
    > >> >
    > >> >End Sub
    > >> >
    > >> >
    > >> >
    > >> >Sincerely,
    > >> >
    > >> >
    > >> >--
    > >> >S. Justin Gengo, MCP
    > >> >Web Developer
    > >> >
    > >> >
    > >> >Free code library at:
    > >> >www.aboutfortunate.com
    > >> >
    > >> >"Out of chaos comes order."
    > >> > Nietzche
    > >> >
    > >> >
    > >> >"Will" <> wrote in message
    > >> >news:070f01c366ac$3004e0e0$...
    > >> >> I'm writing a control. One of the things this control
    > >> does
    > >> >> is render three listboxes on the page. I populate

    > one of
    > >> >> these boxes and leave the others empty. I include

    > this
    > >> >> control in my asp.net page using a register directive
    > >> and
    > >> >> placing a custom control tag where I want it to

    > appear.
    > >> >>
    > >> >> The problem I am having is that when I select

    > something
    > >> in
    > >> >> the populated listbox I want to fire off an event.

    > If I
    > >> >> put

    > OnSelectedIndexChange="controlID.MyEventFunction" in
    > >> >> the tag everything complies fine, but nothing happens
    > >> when
    > >> >> I select something in the listbox. how do I create an
    > >> >> event in my control and tie it to the event of

    > selecting
    > >> >> something in the listbox?
    > >> >>
    > >> >> Details are most helpful, thank you
    > >> >
    > >> >
    > >> >.
    > >> >

    > >
    > >
    > >.
    > >
    James Zhuo, Aug 20, 2003
    #5
  6. James,

    AutoEventWireUp is an attribute of the page object itself.

    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="default.aspx.vb"
    Inherits="WebLab._default"%>

    (It's set to false if you're using a code behind page.)

    Sincerely,

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche


    "James Zhuo" <> wrote in message
    news:...
    > The point about AutoEventWireup, and where is this attribute set?
    > Is autoeventwireup something that is C# specific or is that also used with
    > VB
    >
    > "rory" <> wrote in message
    > news:0ae001c366d8$b6ebc660$...
    > >
    > > Yes this will work if it is defined within the page and
    > > not in codebehind. However, you may need to set
    > > the 'AutoEventWireup' directive to True. This will also
    > > saving you having to write code to attach to specific
    > > events (ie handles)
    > >
    > >
    > >
    > > >-----Original Message-----
    > > >Will,
    > > >
    > > >Sorry, I'm not certain about either. I think I could come

    > > up with the c#
    > > >equivalent if I had to but maybe someone who knows c#

    > > better than I do (I'm
    > > >just learning it) could show the proper formatting of

    > > this subroutine. I'm
    > > >also not positive if this works exactly the same way if

    > > you don't use a
    > > >codebehind page. I use codebehind for everything I do.
    > > >
    > > >Sincerely,
    > > >
    > > >--
    > > >S. Justin Gengo, MCP
    > > >Web Developer
    > > >
    > > >Free code library at:
    > > >www.aboutfortunate.com
    > > >
    > > >"Out of chaos comes order."
    > > > Nietzche
    > > >
    > > >
    > > >"Will" <> wrote in message
    > > >news:08f801c366b8$6c73a640$...
    > > >> Thanks, I think that will work great.. I'm coding in C#
    > > >> though, how do I use that handles statement that way?
    > > >> Also, will this still work if I put it in my class
    > > >> definitions instead of in a code behind in the page?
    > > >> Thanks again
    > > >>
    > > >>
    > > >> Will
    > > >>
    > > >>
    > > >>
    > > >> >-----Original Message-----
    > > >> >Will,
    > > >> >
    > > >> >That event is already defined for you.
    > > >> >
    > > >> >Take out the "OnSelectedIndexChanged" event from your
    > > >> control. That is the
    > > >> >client side event. You want the server side one.
    > > >> >
    > > >> >Now set the list box's AutoPostBack property to "True".
    > > >> >
    > > >> >In your code behind page use this:
    > > >> >
    > > >> >Private Sub ListBox1_SelectedIndexChanged(ByVal sender

    > > As
    > > >> Object, ByVal e As
    > > >> >System.EventArgs) Handles ListBox1.SelectedIndexChanged
    > > >> >
    > > >> >End Sub
    > > >> >
    > > >> >
    > > >> >
    > > >> >Sincerely,
    > > >> >
    > > >> >
    > > >> >--
    > > >> >S. Justin Gengo, MCP
    > > >> >Web Developer
    > > >> >
    > > >> >
    > > >> >Free code library at:
    > > >> >www.aboutfortunate.com
    > > >> >
    > > >> >"Out of chaos comes order."
    > > >> > Nietzche
    > > >> >
    > > >> >
    > > >> >"Will" <> wrote in message
    > > >> >news:070f01c366ac$3004e0e0$...
    > > >> >> I'm writing a control. One of the things this control
    > > >> does
    > > >> >> is render three listboxes on the page. I populate

    > > one of
    > > >> >> these boxes and leave the others empty. I include

    > > this
    > > >> >> control in my asp.net page using a register directive
    > > >> and
    > > >> >> placing a custom control tag where I want it to

    > > appear.
    > > >> >>
    > > >> >> The problem I am having is that when I select

    > > something
    > > >> in
    > > >> >> the populated listbox I want to fire off an event.

    > > If I
    > > >> >> put

    > > OnSelectedIndexChange="controlID.MyEventFunction" in
    > > >> >> the tag everything complies fine, but nothing happens
    > > >> when
    > > >> >> I select something in the listbox. how do I create an
    > > >> >> event in my control and tie it to the event of

    > > selecting
    > > >> >> something in the listbox?
    > > >> >>
    > > >> >> Details are most helpful, thank you
    > > >> >
    > > >> >
    > > >> >.
    > > >> >
    > > >
    > > >
    > > >.
    > > >

    >
    >
    S. Justin Gengo, Aug 21, 2003
    #6
  7. S. Justin Gengo

    James Zhuo Guest

    Thanx Justin
    I think it's because i am always code behind with VS. That's why i never had
    to use it.

    Thanx for clearing it up for me. Cheers.

    James


    "S. Justin Gengo" <> wrote in message
    news:u%...
    > James,
    >
    > AutoEventWireUp is an attribute of the page object itself.
    >
    > <%@ Page Language="vb" AutoEventWireup="false"

    Codebehind="default.aspx.vb"
    > Inherits="WebLab._default"%>
    >
    > (It's set to false if you're using a code behind page.)
    >
    > Sincerely,
    >
    > --
    > S. Justin Gengo, MCP
    > Web Developer
    >
    > Free code library at:
    > www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzche
    >
    >
    > "James Zhuo" <> wrote in message
    > news:...
    > > The point about AutoEventWireup, and where is this attribute set?
    > > Is autoeventwireup something that is C# specific or is that also used

    with
    > > VB
    > >
    > > "rory" <> wrote in message
    > > news:0ae001c366d8$b6ebc660$...
    > > >
    > > > Yes this will work if it is defined within the page and
    > > > not in codebehind. However, you may need to set
    > > > the 'AutoEventWireup' directive to True. This will also
    > > > saving you having to write code to attach to specific
    > > > events (ie handles)
    > > >
    > > >
    > > >
    > > > >-----Original Message-----
    > > > >Will,
    > > > >
    > > > >Sorry, I'm not certain about either. I think I could come
    > > > up with the c#
    > > > >equivalent if I had to but maybe someone who knows c#
    > > > better than I do (I'm
    > > > >just learning it) could show the proper formatting of
    > > > this subroutine. I'm
    > > > >also not positive if this works exactly the same way if
    > > > you don't use a
    > > > >codebehind page. I use codebehind for everything I do.
    > > > >
    > > > >Sincerely,
    > > > >
    > > > >--
    > > > >S. Justin Gengo, MCP
    > > > >Web Developer
    > > > >
    > > > >Free code library at:
    > > > >www.aboutfortunate.com
    > > > >
    > > > >"Out of chaos comes order."
    > > > > Nietzche
    > > > >
    > > > >
    > > > >"Will" <> wrote in message
    > > > >news:08f801c366b8$6c73a640$...
    > > > >> Thanks, I think that will work great.. I'm coding in C#
    > > > >> though, how do I use that handles statement that way?
    > > > >> Also, will this still work if I put it in my class
    > > > >> definitions instead of in a code behind in the page?
    > > > >> Thanks again
    > > > >>
    > > > >>
    > > > >> Will
    > > > >>
    > > > >>
    > > > >>
    > > > >> >-----Original Message-----
    > > > >> >Will,
    > > > >> >
    > > > >> >That event is already defined for you.
    > > > >> >
    > > > >> >Take out the "OnSelectedIndexChanged" event from your
    > > > >> control. That is the
    > > > >> >client side event. You want the server side one.
    > > > >> >
    > > > >> >Now set the list box's AutoPostBack property to "True".
    > > > >> >
    > > > >> >In your code behind page use this:
    > > > >> >
    > > > >> >Private Sub ListBox1_SelectedIndexChanged(ByVal sender
    > > > As
    > > > >> Object, ByVal e As
    > > > >> >System.EventArgs) Handles ListBox1.SelectedIndexChanged
    > > > >> >
    > > > >> >End Sub
    > > > >> >
    > > > >> >
    > > > >> >
    > > > >> >Sincerely,
    > > > >> >
    > > > >> >
    > > > >> >--
    > > > >> >S. Justin Gengo, MCP
    > > > >> >Web Developer
    > > > >> >
    > > > >> >
    > > > >> >Free code library at:
    > > > >> >www.aboutfortunate.com
    > > > >> >
    > > > >> >"Out of chaos comes order."
    > > > >> > Nietzche
    > > > >> >
    > > > >> >
    > > > >> >"Will" <> wrote in message
    > > > >> >news:070f01c366ac$3004e0e0$...
    > > > >> >> I'm writing a control. One of the things this control
    > > > >> does
    > > > >> >> is render three listboxes on the page. I populate
    > > > one of
    > > > >> >> these boxes and leave the others empty. I include
    > > > this
    > > > >> >> control in my asp.net page using a register directive
    > > > >> and
    > > > >> >> placing a custom control tag where I want it to
    > > > appear.
    > > > >> >>
    > > > >> >> The problem I am having is that when I select
    > > > something
    > > > >> in
    > > > >> >> the populated listbox I want to fire off an event.
    > > > If I
    > > > >> >> put
    > > > OnSelectedIndexChange="controlID.MyEventFunction" in
    > > > >> >> the tag everything complies fine, but nothing happens
    > > > >> when
    > > > >> >> I select something in the listbox. how do I create an
    > > > >> >> event in my control and tie it to the event of
    > > > selecting
    > > > >> >> something in the listbox?
    > > > >> >>
    > > > >> >> Details are most helpful, thank you
    > > > >> >
    > > > >> >
    > > > >> >.
    > > > >> >
    > > > >
    > > > >
    > > > >.
    > > > >

    > >
    > >

    >
    >
    James Zhuo, Aug 21, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bloody Viking

    JSF event-handling question

    Bloody Viking, Feb 1, 2008, in forum: Java
    Replies:
    0
    Views:
    407
    Bloody Viking
    Feb 1, 2008
  2. Mark Tarver
    Replies:
    22
    Views:
    1,302
    J Kenneth King
    Apr 26, 2009
  3. Peter
    Replies:
    34
    Views:
    1,936
    James Kanze
    Oct 17, 2009
  4. Forch

    Event Handling Question

    Forch, Jun 13, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    128
    Brock Allen
    Jun 13, 2005
  5. Louis

    Event Handling Question

    Louis, Aug 6, 2007, in forum: Javascript
    Replies:
    9
    Views:
    102
    korisu
    Sep 2, 2007
Loading...

Share This Page