I tryed this:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
Inherits="WebApplication5.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="
http://schemas.microsoft.com/intellisense/ie5">
<script type="text/javascript" language="javascript">
function openWarningPopup()
{
alert("this is a message");
var varProgram = document.getElementById("TextBox1");
varProgram.value = "HAHAHA";
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server"
OnClick="openWarningButton">
<asp
ropDownList id="DropDownList1" style="Z-INDEX: 101; LEFT: 60px;
POSITION: absolute; TOP: 64px" runat="server"
AutoPostBack="True"></asp
ropDownList>
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 292px; POSITION:
absolute; TOP: 69px" runat="server" Text="Button" ></asp:Button>
<asp
ataGrid id=DataGrid1 style="Z-INDEX: 103; LEFT: 54px; POSITION:
absolute; TOP: 127px" runat="server" DataSource="<%# dataSet11 %>"
DataMember="JOBS">
</asp
ataGrid>
<asp:TextBox id="TextBox1" style="Z-INDEX: 104; LEFT: 58px; POSITION:
absolute; TOP: 92px" runat="server"></asp:TextBox>
<asp:Button id="btnTransfer" style="Z-INDEX: 105; LEFT: 468px; POSITION:
absolute; TOP: 78px" runat="server" Text="Next Page"></asp:Button>
</form>
</body>
</HTML>
-----------------------------
and in the .cs
private void Page_Load(object sender, System.EventArgs e)
{
Button1.Attributes.Add("onclick", "openWarningPopup()");
}
the only thig I don't understand now is why it is working when I use the
event in the form
<form id="Form1" method="post" runat="server"
OnClick="openWarningButton">
but not in the button
<asp:Button id="Button1" OnClick="openWarningButton" runat="server"
Text="Button" ></asp:Button>