<html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Testing Page</title> <script type="text/javascript" language="javascript"> function TestingCodeBehind1() { document.getElementById('<%= Label1.ClientID %>').innerHTML = '<%= TestingCodeBehind() %>'; return false; } function TestingCodeBehind2() { document.getElementById('<%= Button2.ClientID %>').click(); } </script> </head> <body> <form id="form1" runat="server"> <table> <tr> <td> <input id="Button1" type="button" value="Button One" onclick="javascript:TestingCodeBehind1()" /><br /> <asp:Button ID="Button2" runat="server" Text="" OnClick="ClickedME" /><br /> <input id="Button3" type="button" value="Button two" onclick="javascript:TestingCodeBehind2()" /><br /> <asp:Label ID="Label1" runat="server" Text=""></asp:Label> </td> </tr> </table> </form> </body> </html>
protected void Page_Load(object sender, EventArgs e) { Button2.Attributes.Add("style", "visibility :hidden"); } protected string TestingCodeBehind() { 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(); }
Login to post response