OnClick Event name for Web page

Discussion in 'ASP .Net' started by tshad, Mar 10, 2010.

  1. tshad

    tshad Guest

    I am trying to figure out the OnXXXX convention for an event.

    It doesn't seem to be needed in an Windows Form page.

    But it seems to be needed on a web page.

    If I set up a User Control as so:

    ******************************************************
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace WebApplication2
    {
    public delegate void OwnerChangedEventHandler(string newOwner);

    public partial class WebUserControl1 : System.Web.UI.UserControl
    {

    public event OwnerChangedEventHandler OwnerChanged;
    private string owner;

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    public string CarOwner
    {
    get { return this.owner; }
    set
    {
    this.owner = value;

    if (this.OwnerChanged != null)
    this.OwnerChanged(value);
    }
    }

    }
    }
    ******************************************************

    In my asp.net page I have:

    ********************************************************
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
    Inherits="WebApplication2._Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ Register TagPrefix="uc" TagName="Spinner" Src="~/WebUserControl1.ascx"
    %>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <uc:Spinner id="Spinner1" runat="server" />

    </div>
    </form>
    </body>
    </html>
    ********************************************************

    In my Page_Load, if I do:

    Spinner1.

    Intellisense shows me my event: OwnerChanged.

    But if I put a space in my "<uc:Spinner" tag, I get a whole bunch of OnXXXX
    selections in Intellisense but no "OnOwnerChanged:" or "OwnerChanged".

    So I can subscribe to my event in my Page_Unload as:

    Spinner1.OwnerChanged += car_OwnerChanged;

    But I can't seem to do the same from my uc:Spinner tag.

    Why is that?


    I also tried to add the following to my code page and intellisense still
    doesn't see it (I did it as protected and public).



    protected virtual void OnOwnerChanged(EventArgs e)

    {

    }


    Thanks,

    Tom
     
    tshad, Mar 10, 2010
    #1
    1. Advertising

  2. tshad

    Andy O'Neill Guest

    "tshad" <> wrote in message
    news:%...
    >I am trying to figure out the OnXXXX convention for an event.

    <<>>
    > So I can subscribe to my event in my Page_Unload as:
    >
    > Spinner1.OwnerChanged += car_OwnerChanged;
    >
    > But I can't seem to do the same from my uc:Spinner tag.
    >
    > Why is that?


    asp.net code runs on the server.
    ( There are exceptions like generated javascript validation, but largely
    speacking).
    There isn't code running on the client.
    So your user changes data on the client, hits the submit button and it goes
    back to the server.
    Your code then does stuff on the server, sends the page back to the client.
    So if you look at it from the 10,000 feet view you have a submit event which
    generates the page cycle.
    Controls either submit (back to the server) or do nothing in terms of CLR
    code events.

    In a windows app, the code is running on the client.
    So you have click events and well, all sorts.

    Since browser based applications are in fashion, people want browser based.
    But....
    They still use word and excel etc.
    So they also want "richly interactive" applications.
    In short, they want windows interaction but in a browser.
    Which is where ajax and silverlight come in.
    Ajax sends bits back to the server, silverlight runs on the client.
     
    Andy O'Neill, Mar 10, 2010
    #2
    1. Advertising

  3. tshad

    tshad Guest

    I understand that but

    How do I subscribe from my tag?

    I can't seem to get it to show on the aspx page - (OnClick, OnTextChanged
    etc)

    Thanks,

    Tom
    "Andy O'Neill" <> wrote in message
    news:27Jln.354913$2...
    >
    > "tshad" <> wrote in message
    > news:%...
    >>I am trying to figure out the OnXXXX convention for an event.

    > <<>>
    >> So I can subscribe to my event in my Page_Unload as:
    >>
    >> Spinner1.OwnerChanged += car_OwnerChanged;
    >>
    >> But I can't seem to do the same from my uc:Spinner tag.
    >>
    >> Why is that?

    >
    > asp.net code runs on the server.
    > ( There are exceptions like generated javascript validation, but largely
    > speacking).
    > There isn't code running on the client.
    > So your user changes data on the client, hits the submit button and it
    > goes back to the server.
    > Your code then does stuff on the server, sends the page back to the
    > client.
    > So if you look at it from the 10,000 feet view you have a submit event
    > which generates the page cycle.
    > Controls either submit (back to the server) or do nothing in terms of CLR
    > code events.
    >
    > In a windows app, the code is running on the client.
    > So you have click events and well, all sorts.
    >
    > Since browser based applications are in fashion, people want browser
    > based.
    > But....
    > They still use word and excel etc.
    > So they also want "richly interactive" applications.
    > In short, they want windows interaction but in a browser.
    > Which is where ajax and silverlight come in.
    > Ajax sends bits back to the server, silverlight runs on the client.
     
    tshad, Mar 10, 2010
    #3
  4. tshad

    Andy O'Neill Guest

    "tshad" <> wrote in message
    news:...
    >I understand that but
    >
    > How do I subscribe from my tag?
    >
    > I can't seem to get it to show on the aspx page - (OnClick, OnTextChanged
    > etc)



    Then you don't understand "that".
    You have no events on a web page NONE other than submit.
     
    Andy O'Neill, Mar 10, 2010
    #4
    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. JerryG
    Replies:
    0
    Views:
    426
    JerryG
    Dec 20, 2005
  2. Noozer
    Replies:
    3
    Views:
    4,244
    Noozer
    Sep 5, 2005
  3. bob
    Replies:
    3
    Views:
    188
  4. Replies:
    2
    Views:
    259
  5. Replies:
    4
    Views:
    185
Loading...

Share This Page