Javascript alert box and confirmation box in ASP.NET

In HTML, the code will be:

<input type="submit" name="ButtonNote" value="Note" id="ButtonNote"
onclick="alert('Alert message appears in here.');" />

<input type="submit" name="ButtonDelete" value="Delete" id="ButtonDelete"
onclick="return confirm('Are you sure you want to delete?');" />

In ASP.NET, the VB code to accomplish the same thing will be:

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
   If (Not Page.IsPostBack) Then
      Me.ButtonNote.Attributes.Add("onclick", _
      "alert('Alert message appears in here.');")
      Me.ButtonDelete.Attributes.Add("onclick", _
      "return confirm('Are you sure you want to delete?');")
   End If
End Sub

Source: http://aspnet.4guysfromrolla.com/articles/021104-1.aspx

Advertisements

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: