Hi,
I have two questions regarding opening a rad window. Please note in both scenario's I don't want to use the radalert or radconfirm dialog boxes, I want to be able to display my own message box.
First question, I have a page with a radgrid and am using linkbuttons in the CommandItemTemplate to perform add/updates/deletes and everything works great. When a user adds a new record, I perform validation that checks for a duplicate value against the database or a null value. If a duplicate'null value is found then I open a radwindow that displays a message to the user that a duplicate/null value has been found and again this works great. The problem is that when the radwindow opens a postback occurs. I don't want this to happen.
I have read the article Calling radalert from codebehind (all versions of RadWindow) and cannot figure out how top apply this to my code. The scenario where I am calling the radwindow is a little different. The code that opens the the rad window is in another module.
Here is the code that calls the radwindow;
Here's is the code that opens the rad window, notice that I am sending the radwindow control that is used on the page that is calling the procedure.
So my question is how do I prevent the radwidow from causing a postback?
Thank you for your help.
I have two questions regarding opening a rad window. Please note in both scenario's I don't want to use the radalert or radconfirm dialog boxes, I want to be able to display my own message box.
First question, I have a page with a radgrid and am using linkbuttons in the CommandItemTemplate to perform add/updates/deletes and everything works great. When a user adds a new record, I perform validation that checks for a duplicate value against the database or a null value. If a duplicate'null value is found then I open a radwindow that displays a message to the user that a duplicate/null value has been found and again this works great. The problem is that when the radwindow opens a postback occurs. I don't want this to happen.
I have read the article Calling radalert from codebehind (all versions of RadWindow) and cannot figure out how top apply this to my code. The scenario where I am calling the radwindow is a little different. The code that opens the the rad window is in another module.
Here is the code that calls the radwindow;
<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 IfHere's is the code that opens the rad window, notice that I am sending the radwindow control that is used on the page that is calling the procedure.
Public 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 SubSo my question is how do I prevent the radwidow from causing a postback?
My 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 SubThank you for your help.