dev-exchange.com logo

dev-exchange.com latest topics RSS feed

Book mark: Add http://www.dev-exchange.com/cms_view_article.php?aid=9&start=0 to your delicious account Add http://www.dev-exchange.com/cms_view_article.php?aid=9&start=0 to your digg account Add http://www.dev-exchange.com/cms_view_article.php?aid=9&start=0 to your blinklist account Add http://www.dev-exchange.com/cms_view_article.php?aid=9&start=0 to your reddit account Add http://www.dev-exchange.com/cms_view_article.php?aid=9&start=0 to Dzone Add http://www.dev-exchange.com/cms_view_article.php?aid=9&start=0 to your furl account Add http://www.dev-exchange.com/cms_view_article.php?aid=9&start=0 to your stumble account Add http://www.dev-exchange.com/cms_view_article.php?aid=9&start=0 to your Yahoo myweb account
Article Menu
Google
ColdFusion MX
PHP
ASP
ASP.Net
XML-XSLT
JavaScript
SQL Server
AJAX
 


 
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.
Rating: 0.00/5.00 [0]

Comments
No comments were made for this article
 

All times are GMT

Jump to:  
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


© 2008 dev-exchange.com
Powered by phpBB. Theme DEVPPL.