This example will introduce you to Anthem and show how similar it is to "normal"
ASP.NET development.
You're going to add an anthem:Button and an anthem:Label
control to a page. Clicking the button will modify the label to contain the current
date and time.
Example
Click the button to update the label next to it with the current time.
Steps
-
Add a Register directive to the top of your page:
<%@ Register TagPrefix="anthem" Namespace="Anthem" Assembly="Anthem" %>
-
Add an anthem:Button control to your page:
<anthem:Button id="button" runat="server" Text="Click Me!" />
-
Add an anthem:Label control to your page:
<anthem:Label id="label" runat="server" />
-
Add a handler for the button's Click event either by double-clicking
on the button in the designer or by adding an OnClick attribute to
the button's tag:
<anthem:Button id="button" runat="server" Text="Click Me!" OnClick="button_Click"
/>
-
Implement the handler in your code behind class or in a server-side script block
in your page. Set the Text property like a normal Label
control:
<script runat="server">
void button_Click(object sender, EventArgs e)
{
label.Text = DateTime.Now.ToString();
}
</script>
Remarks
As you can see, an anthem:Button control is just like an asp:Button
control. It has the same Text property, the same Click
event, and everything else the asp:Button control has. This is because
the Anthem.Button class derives from the System.Web.UI.WebControls.Button
class.
Likewise, the anthem:Label control is just like the asp:Label
control.