Hi guys,
I am stuck with something here. Basically I wanted a delete button for my docks, so I implemented the dock custom command which when user clicks firs the command and deletes the dock. I also needed confirmation on it so I implemented confirmation for client side. The only problem now is that I have to check something else as well before I delete the dock, so I have this database procedure which checks and returns more then 0 if there is something, then I show an error message saying that user needs to delete that thing before they can delete dock, but my custom command doesn't fire the postback although I have got postback enabled. Is there anyway to ajaxify this thing so that user see the error message which I want to show? Here is the code;
here is the code file;
here is the aspx file;
Thanks
Atiq
I am stuck with something here. Basically I wanted a delete button for my docks, so I implemented the dock custom command which when user clicks firs the command and deletes the dock. I also needed confirmation on it so I implemented confirmation for client side. The only problem now is that I have to check something else as well before I delete the dock, so I have this database procedure which checks and returns more then 0 if there is something, then I show an error message saying that user needs to delete that thing before they can delete dock, but my custom command doesn't fire the postback although I have got postback enabled. Is there anyway to ajaxify this thing so that user see the error message which I want to show? Here is the code;
here is the code file;
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init |
createDocks() |
End Sub |
Sub createDocks() |
Try |
Dim dr As IDataReader = "Calling from the database here" |
While dr.Read() |
Dim aDock As New RadDock() |
aDock.DockMode = DockMode.Docked |
aDock.UniqueName = Guid.NewGuid().ToString() |
aDock.ID = CStr(dr.Item("ID")) |
aDock.Title = CStr(dr.Item("Title")) |
Dim custCMD As New DockCommand() |
custCMD.Name = "deleteCMD" |
custCMD.CssClass = "pullImage" |
custCMD.Text = "Delete" |
custCMD.AutoPostBack = True |
custCMD.OnClientCommand = "CustomCommand" |
aDock.Commands.Add(custCMD) |
AddHandler aDock.Command, AddressOf dock_Command |
aDock.DefaultCommands = Dock.DefaultCommands.None |
Dim triger As New AsyncPostBackTrigger() |
triger.ControlID = aDock.ID |
triger.EventName = "DockPositionChanged" |
uPanel.Triggers.Add(triger) |
rdZone.Controls.Add(aDock) |
End While |
dr.Dispose() |
Catch ex As Exception |
Dim exp As New exHandle |
lblmsg.Text = exp.processExp(ex, "", Now) |
End Try |
End Sub |
Sub dock_Command(ByVal sender As Object, ByVal e As DockCommandEventArgs) |
If Session("ClassID") Is Nothing Then |
mainPNL.Visible = False |
notAllowed.Visible = True |
Else |
If e.Command.Name = "deleteCMD" Then |
Dim aDock As RadDock = sender |
Dim ID_int As Integer = aDock.ID |
Dim ClassID As Integer = CInt(Session("ClassID")) |
Dim SetsCount As Integer = "Calling from database to check if there is anything" |
If (SetsCount > 0) Then |
"NOT SHOWING THIS THING HERE." |
lblmsg.Text = "<BR>There are " & SetsCount & " in this section. Please delete them first." |
Else |
'delete from database here and release session |
ScriptManager.RegisterStartupScript(uPanel, Me.[GetType](), "RemoveDock", String.Format("function _removeDock() {{" & Chr(13) & "" & Chr(10) & "" & Chr(9) & "Sys.Application.remove_load(_removeDock);" & Chr(13) & "" & Chr(10) & "" & Chr(9) & "$find('{0}').undock();" & Chr(13) & "" & Chr(10) & "" & Chr(9) & "$get('{1}').appendChild($get('{0}'));" & Chr(13) & "" & Chr(10) & "" & Chr(9) & "$find('{0}').doPostBack('DockPositionChanged');" & Chr(13) & "" & Chr(10) & "}};" & Chr(13) & "" & Chr(10) & "Sys.Application.add_load(_removeDock);", (DirectCast(sender, RadDock)).ClientID, uPanel.ClientID), True) |
End If |
End If |
End If |
End Sub |
here is the aspx file;
<asp:ScriptManager id="ScriptManager" runat="server"/> |
<radT:radformdecorator id="FormDecorator1" runat="server" decoratedcontrols="all" |
skin="Default"> |
</radT:radformdecorator> |
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div> |
<script type="text/javascript"> |
function GetRadWindow() |
{ |
var oWindow = null; |
if (window.radWindow) oWindow = window.radWindow; |
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; |
return oWindow; |
} |
function returnToParent() |
{ |
var oWnd = GetRadWindow(); |
oWnd.close(); |
} |
function CustomCommand(dock, args) |
{ |
//You can implement your custom logic in this method |
if (!confirm("Are you sure you want to delete this section?")) |
{ |
args.set_cancel(true); |
} |
} |
</script> |
<table width="100%" id="notAllowed" runat="server"> |
<tr> |
<td>You don't have permission to view this page. Please contact support.<br /> |
<input id="Button1" onclick="returnToParent(); return false;" type="button" |
value="Close" class="button" /></td> |
</tr> |
</table> |
<asp:Panel runat="server" ID="mainPNL" Width="500"> |
<table cellpadding="0" cellspacing="0" border="0" width="100%"> |
<tr> |
<td> |
Select a section and drag it up and down to change its order. |
<asp:Label ID="lblmsg" runat="server" Font-Bold="True" |
ForeColor="#C00000"></asp:Label> |
</td> |
</tr> |
<tr> |
<td> |
<radT:raddocklayout runat="server" id="rdLayout" Skin="Sunset"> |
<radT:raddockzone runat="server" id="rdZone" Width="100%" Skin="Sunset"> |
</radT:raddockzone> |
<div style="display:none"> |
Hidden UpdatePanel, which is used to receive the new dock controls. |
We will move them with script to the desired initial dock zone. |
<asp:updatepanel runat="server" id="uPanel"> |
<triggers> |
</triggers> |
</asp:updatepanel> |
</div> |
</radT:raddocklayout> |
</td> |
</tr> |
<tr> |
<td><br /> |
<input id="closeBTN" onclick="returnToParent(); return false;" type="button" |
value="Exit" class="button" /> |
|
<%-- <asp:Button ID="exitBTN" runat="server" Text="Exit" Width="130px" |
CausesValidation="False" />--%> |
<asp:Button ID="resetBTN" runat="server" |
CausesValidation="False" Text="Reset" Width="130px" /> |
|
<asp:Button ID="submitBTN" runat="server" Text="Save & Exit" Width="130px" |
CausesValidation="False" /> |
</td> |
</tr> |
</table> |
</asp:Panel> |
Thanks
Atiq