It is quite easy to add JavaScript to a specific server control that resides on an ASP.NET page. Let's take a look at the button server control as an example. If you drag and drop a Button HTML server control (HtmlInputButton Class) onto a page using either Microsoft Visual Studio® .NET or the ASP.NET Web Matrix and run it as a server control, it should have the following construction:
This is a normal button that can be programmatically manipulated in the code-behind or server-side script of an ASP.NET page. For example, to assign the button text when the page is generated, simply use the value property of the button after this element is turned into an HTML server control (right-click on the control and select Run As Server Control).
Visual Basic .NET
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Value = DateTime.Now.ToString()
End Sub
Visual C# .NET
void Page_Load(object sender, EventArgs e) {
Button1.Value = DateTime.Now.ToString();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment