"Gary" <g@nospam.comwrote in message
news:e5**************@TK2MSFTNGP05.phx.gbl...
I am currently new to .NET, as you can probably tell by my last two or
three
threads!!!
Anyway, I am using code behind as much as possible - and am curious about
the way in which functions can be triggered.
It seems if I use an <asp:button...control, I can assign a function
which
exisits on my .CS file, for example:
<asp:button... OnClick="Button_Click">
However, this function is not available on for example a standard <Atag:
<A href="#" OnClick="Button_Click" runat="server" />
Each webcontrol implements its own set of "events" for want of a better
term - lots of controls have very similar events. However, server-side code
can include other methods which these events can call. E.g. you could write
a server-side method which added a record to a database every time a control
initiated a postback - a pretty pointless thing to do - but you wouldn't
need to write the database code in every event - each event would simply
call the method...
I am *guessing* this is because the button submits the .net form, which
forces the page to read the CS file again, which is when it can execute
the
various functions?
Sort of... ASP.NET adds a couple of hidden fields to the Request.Form
collection which tell it which control initiated the postback, and which
event to run.
My question is, is it possible or sensible to try and access these
functions
without using a form button?
Using the traditional model (i.e. not callbacks via AJAX etc), server-side
code is *only* available through a postback, and a control needs to be
contained within a <formobject for it to be able to initiate a postback...
I appreciate you're new to ASP.NET, so maybe you can describe a bit more
about what you're trying to achieve...?