RE: Mistake in MSDN

From: Rakesh Rajan (RakeshRajan_at_discussions.microsoft.com)
Date: 11/22/04


Date: Mon, 22 Nov 2004 00:55:07 -0800

Hi,

There are a number of free chapters of .NET related books @ ondotnet.com and
wrox.com. Try using those too.

HTH,
Rakesh Rajan

"Jakob Christensen" wrote:

> Hey Vivek,
>
> This is not an error in the documentation. I think you have just
> misunderstood what it says. What it means is that first it will call your
> own client-side javascript function and then it will call a javascript
> function generated by ASP.NET which will submit the form.
>
> You can not make it work the other way around unless you want to use
> RegisterClientSideScript or some other similar mechanism because of the way
> HTTP works.
>
> HTH, Jakob.
>
>
>
> "Vivek Thakur" wrote:
>
> > Hello,
> >
> > I think I have found a mistake in MSDN.
> >
> > I have visual Studio 2003 with MSDN. My problem is very simple: I have a
> > webform with a HTML button control as:
> >
> > <INPUT id="Button1" type="button" value="Button" name="Button1"
> > runat="server" onclick="alert('df');">
> >
> > So its an HTMLServer control which does not submit.
> >
> > I have this code for the button in code behind:
> > private void Button1_ServerClick(object sender, System.EventArgs e)
> > {
> > int h=0;
> > h++;
> > }
> >
> >
> > Now according to MSDN: (Section: ASP.NET Server Control Event
> > Model->Handling a Click Event in Client and Server Code)
> >
> > ***********************************************************************
> > All other HTML controls (those that do not submit a form by default)
> >
> > Include an onclick attribute in the HTML syntax for the control, but follow
> > it with a semicolon (;):
> >
> > <INPUT Type="Button" Runat="Server" Value="caption"
> > onclick="clientfunction();" ...>
> >
> > This causes your function to be called first, before the client-side submit
> > script is called.
> >
> > *************************************************************************
> >
> > Now in my case, its always the client side script which calls first, no
> > matter what I do, even after using the semi-colon.The control still submits,
> > but first
> >
> > the Javascript fires. So how can we make sure that our server side event is
> > executed first and than the client side script
> >
> > runs (without using RegisterScriptBlock etc).
> >
> > Is the above example a mistake in MSDN??
> >
> > Vivek Thakur
> > www.vivekthakur.com
> >
> >
> >