:: Home     :: MS Dynamics CRM     :: .Net 1.1     :: .Net 2.0     :: Sharepoint Portal     :: Ajax


Using Javascript with ASP.NET Form Elements 

Adding simple pieces of Javascript to an Asp.net page can be acheived by adding to the attributes of the particular imagebutton or linkbutton, for example: 

if its normal ASP.Net Button then you can write the code as below

btnUpdate.Attributes.Add("onClick", "return confirm('confirm delete?');")

or if its a DataGrid button or checkbox then you can use the code as below

Private Sub dgMegasolutions_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles dtgBeds.ItemDataBound
      If (e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem) Then
         Dim Active As CheckBox = CType(e.Item.FindControl("active"), CheckBox)
         Active.Attributes.Add("onClick", "return setVal(this);")
      End If
   Catch exc As Exception
Me, exc)
   End Try
End Sub

Copyright 2005-2015, Megasolutions Ltd  |   Privacy Policy