I am creating toolbar buttons on the page load.
I want to do on the server side - code behind page:
Here is my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
'create xml button list
With
SessionWrapper.ToolBarButtons
.Clear()
.Add(ToolBarButtons.ButtonText.Retrieve,
True)
.Add(ToolBarButtons.ButtonText.Delete,
True)
.Add(ToolBarButtons.ButtonText.Save,
True)
.Add(ToolBarButtons.ButtonText.Export,
True)
.Add(ToolBarButtons.ButtonText.Print)
.Build()
End With
'build tool bar
rtbReasonCode.LoadXml(SessionWrapper.ToolBarButtons.XMLButtonList)
End If
Dim btnbutton1 As New Telerik.Web.UI.RadToolBarButton
btnbutton1 =
CType(rtbReasonCode.FindControl("i2"), Telerik.Web.UI.RadToolBarButton)
btnbutton1.Attributes.Add(
"OnClick", "return confirm('Confirm Delete?');")
Dim btnbutton As New Telerik.Web.UI.RadToolBarButton
btnbutton =
CType(rtbReasonCode.FindControl("i4"), Telerik.Web.UI.RadToolBarButton)
btnbutton.Attributes.Add(
"OnClick", "return confirm('Confirm Save?');")
'display custom control
Master.DisplayCustomControl(_CustomCtrl)
End Sub
-------------------------------------------------------
Private
Sub rtbReasonCode_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles rtbReasonCode.ButtonClick
Try
Dim [text] As String = e.Item().Text
Dim typeIS As Type = e.Item.GetType()
If TypeOf e.Item Is RadToolBarButton Then
'Call to business layer to save header
If [text] = "Retrieve" Then
GetReasonInfo()
ElseIf [text] = "Delete" Then
DeleteReason()
ElseIf [text] = "Save" Then
SaveReasonInfo()
ElseIf [text] = "Export" Then
'TODO: implement export to excel
'CallExport()
ElseIf [text] = "Print" Then
'TODO: implement print
'CallPrint()
End If
End If
Catch ex As Exception
Log.Fatal(ex)
'Throw
End Try
End Sub
--------------------------------------------
the postback happens on hitting both OK/CANCEL, how to handle this scenario?