or
<asp:TextBox ID="ProductReferenceTextBox" runat="server" Text='<%#Bind("ProductReference") %>' MaxLength="8" AutoPostBack="true" OnTextChanged="ProductReferenceTextBox_TextChanged" /><t:RadInputManager ID="MainInputManager" runat="server"> <t:TextBoxSetting BehaviorID="ProductReferenceBehavior" Validation-Method="ValidateProductCode" Validation-Location="ValidationServices/ProductService.asmx" Validation-ValidateOnEvent="All" Validation-IsRequired="true" />protected void ProductReferenceTextBox_TextChanged(object Sender, EventArgs E){TextBox oSender = (TextBox)Sender;if (IocContainer.ProductDao.Exists(oSender.Text)){ Product eProduct = IocContainer.ProductDao.GetProduct(oSender.Text); GridDataInsertItem oContainer = (GridDataInsertItem)oSender.NamingContainer; Label oLabel = (Label)oContainer.Controls[5].Controls[0]; oLabel.Text = eProduct.StockUnit; } }<telerik:RadScheduler ID="calTaskDisplay" runat="server" DataEndField="EndDate" DataKeyField="TaskId" DataStartField="EndDate" DataSubjectField="TaskName" OnAppointmentCreated="calTaskDisplay_AppointmentCreated" OnDataBound="calTaskDisplay_DataBound" AllowDelete="False" AllowEdit="False" SelectedView="MonthView" DayStartTime="09:00:00" DisplayDeleteConfirmation="False" EditFormDateFormat="d/M/yyyy" EnableAdvancedForm="False" EnableViewState="False" FirstDayOfWeek="Monday" LastDayOfWeek="Friday" WorkDayEndTime="17:00:00" EnableCustomAttributeEditing="true" CustomAttributeNames="status" WorkDayStartTime="09:00:00" OnAppointmentDataBound="calTaskDisplay_AppointmentDataBound"> <DayView DayStartTime="09:00:00" ShowHoursColumn="False" WorkDayEndTime="17:00:00" /> <WeekView DayStartTime="09:00:00" WorkDayStartTime="09:00:00" WorkDayEndTime="17:00:00" /> <AppointmentTemplate> <%#Eval("Subject")%> <input type="text" id="lblStatus" visible="false" title='<%# Eval("Status") %>' /> </AppointmentTemplate> </telerik:RadScheduler>Page_Load(){List<ScheduledTasks> loOtherTasks = loClient.GetScheduledTasks(Session["UserId"].ToString()); calTaskDisplay.DataSource = loOtherTasks; calTaskDisplay.DataBind();}calTaskDisplay_AppointmentDataBound(object sender, SchedulerEventArgs e){ switch (e.Appointment.Attributes["Status"]) { case "Pending": e.Appointment.BackColor = System.Drawing.Color.Red; break; case "pending": e.Appointment.BackColor = System.Drawing.Color.Red; break; case "Complete": e.Appointment.BackColor = System.Drawing.Color.Green; break; case "complete": e.Appointment.BackColor = System.Drawing.Color.Green; break; case "Over due": e.Appointment.BackColor = System.Drawing.Color.Red; break; case "over due": e.Appointment.BackColor = System.Drawing.Color.Red; break; case "Started": e.Appointment.BackColor = System.Drawing.Color.Blue; break; case "started": e.Appointment.BackColor = System.Drawing.Color.Blue; break; default: break;}calTaskDisplay_DataBound(object sender, EventArgs e){foreach (ResourceType resType in calTaskDisplay.ResourceTypes) { resType.AllowMultipleValues = false; }}<CommandItemTemplate > <div style="padding: 5px 5px;"> <asp:LinkButton ID="lbtAdd" runat="server" CommandName="InitInsert" Visible='<%# Not rgvSecurityGroups.MasterTableView.IsItemInserted %>'><asp:Image ID="imgAdd" runat="server" CssClass="css_GFS01_Image_Align" ImageURL="<%$ Resources:Images,AddGreen16%>" /> Add </asp:LinkButton> <asp:LinkButton ID="btnEditSelected" runat="server" CommandName="EditSelected" Visible='<%# rgvSecurityGroups.EditIndexes.Count = 0 and Not rgvSecurityGroups.MasterTableView.IsItemInserted %>'> <asp:Image runat="server" CssClass="css_GFS01_Image_Align" ImageURL="<%$ Resources:Images, EditGreen16%>"/> Edit </asp:LinkButton> <asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" Visible='<%# rgvSecurityGroups.EditIndexes.Count > 0 Or rgvSecurityGroups.MasterTableView.IsItemInserted %>'><asp:Image ID="imgCancel" runat="server" CssClass="css_GFS01_Image_Align" ImageURL="<%$ Resources:Images,CancelGreen16%>" /> Cancel </asp:LinkButton> <asp:LinkButton ID="lbtSaveNew" runat="server" CommandName="PerformInsert" Visible='<%# rgvSecurityGroups.MasterTableView.IsItemInserted%>'><asp:Image ID="imgSaveNew" runat="server" CssClass="css_GFS01_Image_Align" ImageURL="<%$ Resources:Images,SaveButton18%>" /> Save New</asp:LinkButton> <asp:LinkButton ID="lbtDelete" runat="server" CommandName="DeleteSelected" Visible='<%# rgvSecurityGroups.EditIndexes.Count = 0 and Not rgvSecurityGroups.MasterTableView.IsItemInserted %>'><asp:Image ID="imgDelete" runat="server" CssClass="css_GFS01_Image_Align" ImageURL="<%$ Resources:Images,DeleteRed16%>" />Delete </asp:LinkButton> <asp:LinkButton ID="lbtSave" runat="server" CommandName="UpdateEdited" Visible='<%# rgvSecurityGroups.EditIndexes.Count > 0 or rgvSecurityGroups.MasterTableView.IsItemInserted%>'><asp:Image runat="server" CssClass="css_GFS01_Image_Align" ImageURL="<%$ Resources:Images,SaveBlue16%>" /> Update </asp:LinkButton> <asp:LinkButton ID="lbtRefresh" runat="server" CommandName="RebindGrid" ><asp:Image id="imgRefresh" runat="server" CssClass="css_GFS01_Image_Align" ImageURL="<%$Resources:Images, ReloadBlue16 %>" AlternateText ="Refresh Grid" /></asp:LinkButton> </div> </CommandItemTemplate> Private Sub rgvSecurityGroups_InsertCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgvSecurityGroups.InsertCommand Dim InsertedItem As GridDataInsertItem = DirectCast(e.Item.OwnerTableView.GetInsertItem(), GridDataInsertItem) Dim strSecurityGroup As String = DirectCast(InsertedItem("SecurityGroup").Controls(0), TextBox).Text Dim aryParameters(2) As String Dim strMessageType As String = Nothing Dim strMessage As String = Nothing Dim strMessageHeading As String = Nothing If strSecurityGroup Is Nothing Or IsDBNull(strSecurityGroup) Or Len(strSecurityGroup) = 0 Then strMessageType = "Error" strMessageHeading = "Null Value" aryParameters(0) = "Security Group" aryParameters(1) = strSecurityGroup strMessage = UDF_GetErrorMessage("Null Value", aryParameters) USB_DisplayMessage(strMessageType, strMessageHeading, strMessage, "Medium", "Black", Me.rwmMessageBox) Else If pUDF_DuplicateValueCheck(0, strSecurityGroup) = True Then strMessageType = "Error" strMessageHeading = "Duplicate Value" aryParameters(0) = "Security Group" aryParameters(1) = strSecurityGroup strMessage = UDF_GetErrorMessage("Duplicate Value", aryParameters) USB_DisplayMessage(strMessageType, strMessageHeading, strMessage, "Medium", "Black", Me.rwmMessageBox) Else Me.SQLDS_SecurityGroups.InsertCommandType = SqlDataSourceCommandType.Text Me.SQLDS_SecurityGroups.InsertCommand = "EXEC [Security].[DSP_SEL-INS-UPD-DEL-SecurityGroups] 'Insert', DEFAULT, " & strSecurityGroup End If End IfPublic Shared Sub USB_DisplayMessage(ByVal strMessageType As String, ByVal strMessageHeading As String, ByVal strMessage As String, ByVal strMessageSize As String, ByVal strSkin As String, ByVal rwmMessageBox As RadWindowManager) Dim rwdMessage As New RadWindow Dim strNavigation As String = "~/Modules/Central/WBF CTL Message Box.aspx?MessageType=" + strMessageType + "&MessageHeading=" + strMessageHeading + "&Message=" + strMessage rwdMessage.ID = "rwdMessageDetail" rwdMessage.Skin = strSkin Select Case strMessageSize Case "Small" rwdMessage.Height = "250" rwdMessage.Width = "400" Case "Medium" rwdMessage.Height = "300" rwdMessage.Width = "400" End Select rwdMessage.NavigateUrl = strNavigation rwmMessageBox.Windows.Add(rwdMessage) End SubMy second question is regarding the cancelling of the delete event. As in the above scenario I am using the CommandItemTemplate with LinkButtons to perform all the record functions. When the user clicks the delete button I open a radwindow prompting (yes/no buttons) them to confirm the deletion and again this works fine. What I want to be able to do is Cancel the deletion if the user clicks the No button on the rad window. But I can't figure out how to cancel the DeleteCommand if the user clicks the No button to cancel the deletion.
Here is the code that calls the rad window. The code for opening the rad window is the same as listed above.
Private Sub rgvSecurityGroups_DeleteCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgvSecurityGroups.DeleteCommand Dim GridItem As GridDataItem = DirectCast(e.Item, GridDataItem) Dim intSecurityId As Int16 = GridItem.GetDataKeyValue("SecurityID") Dim strSecurityGroup As String = GridItem("SecurityGroup").Text Dim strMessageType As String = Nothing Dim strMessage As String = Nothing Dim strMessageHeading As String = Nothing strMessageType = "Warning" strMessageHeading = "Deleting " + strSecurityGroup strMessage = "You have selected to delete security group " + strSecurityGroup & ". This action will cause this group to be deleted from all Users.<br><br>Do you want to continue?" USB_DisplayMessage(strMessageType, strMessageHeading, strMessage, "Medium", "Black", Me.rwmMessageBox) Me.SQLDS_SecurityGroups.DeleteCommandType = SqlDataSourceCommandType.Text Me.SQLDS_SecurityGroups.DeleteCommand = "EXEC [Security].[DSP_SEL-INS-UPD-DEL-SecurityGroups] 'Delete', " & intSecurityId & ", DEFAULT"End Subfunction OnClientContextMenu(sender, args) { var appointment = args.get_appointment(); if (appointment) { if(appointment.get_attributes().getAttribute("Status") != 2 || appointment.get_attributes().getAttribute("Status") != 3) { //Stop context menu from showing. return; } else { //Show context menu. menu.show(args.get_domEvent()); } }}OnClientAppointmentContextMenu="OnClientContextMenu"<telerik:RadContextMenu ID="RadContextMenu1" runat="server"> <Targets> <telerik:ContextMenuControlTarget ControlID="TextBox1" /> <telerik:ContextMenuControlTarget ControlID="Label1" /> <telerik:ContextMenuControlTarget ControlID="Image1" /> </Targets> <Items> </Items> </telerik:RadContextMenu> Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then RadContextMenu1.DataTextField = "Text" RadContextMenu1.DataNavigateUrlField = "Url" RadContextMenu1.DataFieldID = "ID" RadContextMenu1.DataFieldParentID = "ParentID" RadContextMenu1.DataSource = GenerateSiteData() RadContextMenu1.DataBind() End If End Sub Private Function GenerateSiteData() As ArrayList Dim siteData As New ArrayList() siteData.Add(New SiteDataItem(1, Nothing, "All Sites", "")) siteData.Add(New SiteDataItem(2, 1, "Search Engines", "")) siteData.Add(New SiteDataItem(3, 1, "News Sites", "")) siteData.Add(New SiteDataItem(4, 2, "Yahoo", "http://www.yahoo.com")) siteData.Add(New SiteDataItem(5, 2, "MSN", "http://www.msn.com")) siteData.Add(New SiteDataItem(6, 2, "Google", "http://www.google.com")) siteData.Add(New SiteDataItem(7, 3, "CNN", "http://www.cnn.com")) siteData.Add(New SiteDataItem(8, 3, "BBC", "http://www.bbc.co.uk")) siteData.Add(New SiteDataItem(9, 3, "FOX", "http://www.foxnews.com")) Return siteData End Function Public Class SiteDataItem Private _text As String Private _url As String Private _id As Integer Private _parentId As Integer Public Property Text() As String Get Return _text End Get Set(ByVal value As String) _text = value End Set End Property Public Property Url() As String Get Return _url End Get Set(ByVal value As String) _url = value End Set End Property Public Property ID() As Integer Get Return _id End Get Set(ByVal value As Integer) _id = value End Set End Property Public Property ParentID() As Integer Get Return _parentId End Get Set(ByVal value As Integer) _parentId = value End Set End Property Public Sub New(ByVal id As Integer, ByVal parentId As Integer, ByVal text As String, ByVal url As String) _id = id _parentId = parentId _text = text _url = url End SubEnd Class<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"> </telerik:RadAjaxManagerProxy> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default"> </telerik:RadAjaxLoadingPanel> <div class="localEventContainer"> <asp:Panel ID="ListViewPanel" runat="server"> <div class="localEventTop"><asp:Label ID="lblControlTitle" runat="server"></asp:Label></div> <telerik:RadListView ID="RadListView1" runat="server" AllowPaging="True" DataKeyNames="EventID" ItemPlaceholderID="EventItemContainer" Skin="Black" OnDataBound="RadListView1_DataBound" OnNeedDataSource="RadListView1_NeedDataSource"> <LayoutTemplate> <asp:Panel ID="EventItemContainer" runat="server"></asp:Panel> <table cellpadding="0" cellspacing="0" width="100%;" style="clear: both;"> <tr> <td> <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="RadListView1" PageSize="5"> <Fields> <telerik:RadDataPagerButtonField FieldType="FirstPrev" /> <telerik:RadDataPagerButtonField FieldType="Numeric" /> <telerik:RadDataPagerButtonField FieldType="NextLast" /> </Fields> </telerik:RadDataPager> </td> </tr> </table> </LayoutTemplate> <ItemTemplate> <div class="localEventArticleContainer"> <div class="localEventTitle"> <asp:Label ID="lblEventName" runat="server" Text='<%# Eval("Name") %>'></asp:Label> </div> <div class="localEventDate"> <asp:Label ID="lblDate" runat="server" Text='<%# Eval("Date", "{0:d}") %>'></asp:Label> <asp:Label ID="lblTime" runat="server" Text='<%# Eval("Starttime") %>'></asp:Label> </div> <div class="localEventText"> <asp:Label ID="lblText" runat="server" Text='<%# Eval("LocationName") %>'></asp:Label> </div> <%--<div class="localEventLink"> <asp:HyperLink ID="lblLink" runat="server" Text="Ticnet.se" NavigateUrl='<%# Eval("Url") %>' Target="_blank"></asp:HyperLink> </div>--%> </div> </ItemTemplate> </telerik:RadListView> </asp:Panel> <div class="localEventBottom"></div> </div>protected override void OnInit(EventArgs e) { base.OnInit(e); if (this.Page != null && !this.DesignMode) { RadAjaxManager ajaxManager = RadAjaxManager.GetCurrent(this.Page); if (ajaxManager != null) { ajaxManager.AjaxSettings.AddAjaxSetting(ListViewPanel, ListViewPanel, RadAjaxLoadingPanel1); } lblEventAreaID.Text = EventAreaID.ToString(); } }protected void RadListView1_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e) { RadListView1.DataSource = ReadData("SELECT e.EventID, e.Name,e.Url, ev.Name AS LocationName, et.Date, et.Starttime FROM mp_Event e INNER JOIN mp_EventLocation ev ON e.EventLocationID = ev.EventLocationID INNER JOIN mp_EventTime et on e.EventID = et.EventID WHERE " + "ev.AreaID = @AreaID AND " + "et.Date >= '" + Today + "' ORDER BY Date ASC"); } private SqlDataReader ReadData(string query) { string connString = ConfigurationManager.ConnectionStrings["UnigolfMPTestConnectionString"].ConnectionString; conn = new SqlConnection(connString); conn.Open(); SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("@AreaID", lblEventAreaID.Text); reader = cmd.ExecuteReader(); return reader; } protected void RadListView1_DataBound(object sender, EventArgs e) { reader.Close(); conn.Close(); }