Thursday 26 January 2012

Set ServerSide ConfirmBox

SetAlert(btnSendEmailTest, "Are you sure you want to send this email")

Public Shared Sub SetAlert(ByVal ctrl As WebControl, ByVal Message As String)
 If (HttpContext.Current.Request.Browser.Type.ToUpper().IndexOf("IE") >= 0) Then
     ctrl.Attributes.Add("onclick", "event.returnValue=confirm('" & Message & "?');")  
 Else      
    ctrl.Attributes.Add("onclick", "return confirm('" & Message & "?');")  
 End If
End Sub

C#.Net
 

SetAlert(btnSendEmailTest, "Are you sure you want to send this email")public static void SetAlert(WebControl ctrl, String Message)
{
  if ((HttpContext.Current.Request.Browser.Type.ToUpper().IndexOf("IE") >= 0)) 

  {
    ctrl.Attributes.Add("onclick", ""event.returnValue=confirm('" + Message + "?');");
  }
  else

  {
    ctrl.Attributes.Add("onclick", "return confirm('" & Message & "?');");  } 
}  

No comments:

Post a Comment