<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" language="javascript">
function TestCodeBehind()
{
document.getElementById('<%= Label1.ClientID %>').innerHTML = '<%= CodeBehind() %>';
return false;
}
function TestCodeBehind2()
{
document.getElementById('<%= Button2.ClientID %>').click();
// return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="Sample One" onclick="javascript:TestCodeBehind()" />
<input id="Button3" type="button" value="Sample two" onclick="javascript:TestCodeBehind2()" />
<asp:Button ID="Button2" runat="server" Text="" OnClick="ClickedME" />
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>
.cs
protected void Page_Load(object sender, EventArgs e)
{
Button2.Attributes.Add("style", "visibility :hidden");
}
protected string CodeBehind()
{
return "this is a string from C# code behind " + DateTime.Now.ToString();
}
protected void ClickedME(object sender, EventArgs e)
{
Label1.Text = "You clicked this button on " + DateTime.Now.ToString();
}