|
|
| Article |
MsN
Tech Author
Articles: 7 Comments: 1
|
|
|
| Posted: Fri Jun 08, 2007 2:14 pm |
|
|
It is a common question in ASP.net forums about how to call the VB Script or Java script in server controls so i thought to publish an example here.
In normal html tag we used to call the scripts like
<input type ="button" name="txt" onclick="Alert('This is a test');" />
But in ASP.Net server controls we do not have the design mode attribute to add client side scripting like this.
<asp:Button ID="Button1" runat="server" Text="Button" />
In order to add the onClick event in this text box , attribtes need to add in code behind.
Syntax for this is:
Servercontrol.Attributes.Add("key","value");
Example,
| Code: | Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Button1.Attributes.Add("onClick", "Alert('This is a test');");
End Sub |
It is also possible to add any number of attributes to server control such as style etc...
Please post your comments here if you have any. |
|
|
| Comments |
| No comments were made for this article |
| |
|
All times are GMT
You cannot post articles in this chapter You cannot edit your articles in this chapter You cannot delete your articles in this chapter You cannot rate articles in this chapter
You cannot post comments in this chapter You cannot edit your comments in this chapter You cannot delete your comments in this chapter You cannot rate comments in this chapter
|
|