G
Guest
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
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