T
Tony Johansson
Hello!
Below is the source of the Design window and at the bottom I have the
code-behind file.
I just test this HTML control so I can understand them. In the normal case I
should use webbserver control instead.
I just wonder is not possible to have two event handler for the same
control. In this case I have one event handler Button1_onclick which should
execute on the client and one event hander Button1_ServerClick1 which should
execute on the server for the same html Button ?
When I run this page and click on the Button no event handler is called.
Can somebody explain to me what is happening here ?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
<!--
function Button1_onclick()
{
document.write('Hello');
}
// -->
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" runat="server" style="z-index: 100; left: 0px;
position: absolute; top: 0px"
type="button" value="button" onclick="return Button1_onclick()"
onserverclick="Button1_ServerClick1" />
</div>
</form>
</body>
</html>
In the code-behind file I have the following code
************************************
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Button1_ServerClick1(object sender, EventArgs e)
{
Response.Write("**********Testing ***********");
}
}
//Tony
Below is the source of the Design window and at the bottom I have the
code-behind file.
I just test this HTML control so I can understand them. In the normal case I
should use webbserver control instead.
I just wonder is not possible to have two event handler for the same
control. In this case I have one event handler Button1_onclick which should
execute on the client and one event hander Button1_ServerClick1 which should
execute on the server for the same html Button ?
When I run this page and click on the Button no event handler is called.
Can somebody explain to me what is happening here ?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
<!--
function Button1_onclick()
{
document.write('Hello');
}
// -->
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" runat="server" style="z-index: 100; left: 0px;
position: absolute; top: 0px"
type="button" value="button" onclick="return Button1_onclick()"
onserverclick="Button1_ServerClick1" />
</div>
</form>
</body>
</html>
In the code-behind file I have the following code
************************************
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Button1_ServerClick1(object sender, EventArgs e)
{
Response.Write("**********Testing ***********");
}
}
//Tony