Partial
Public Class DynamicControlTest
Inherits System.Web.UI.Page
Private Property CurrentDockStates() As List(Of DockState)
Get
Dim _currentDockStates As List(Of DockState) = DirectCast(Session("CurrentDockStatesDynamicDocks"), List(Of DockState))
If [Object].Equals(_currentDockStates, Nothing) Then
_currentDockStates =
New List(Of DockState)()
Session(
"CurrentDockStatesDynamicDocks") = _currentDockStates
End If
Return _currentDockStates
End Get
Set(ByVal value As List(Of DockState))
Session(
"CurrentDockStatesDynamicDocks") = value
End Set
End Property
Dim save As Boolean = False
Private Function CreateRadDockFromState(ByVal state As DockState) As RadDock
Dim dock As New RadDock()
dock.DockMode = DockMode.Docked
dock.ID =
String.Format("RadDock{0}", state.UniqueName)
dock.ApplyState(state)
dock.Commands.Add(
New DockCloseCommand())
dock.Commands.Add(
New DockExpandCollapseCommand())
Return dock
End Function
Private Function CreateRadDock() As RadDock
Dim docksCount As Integer = CurrentDockStates.Count
Dim dock As New RadDock()
dock.DockMode = DockMode.Docked
dock.UniqueName = Guid.NewGuid().ToString()
dock.ID =
String.Format("RadDock{0}", dock.UniqueName)
dock.Title =
"Dock"
dock.Text =
String.Format("Added at {0}", DateTime.Now)
dock.Width = Unit.Pixel(300)
dock.Commands.Add(
New DockCloseCommand())
dock.Commands.Add(
New DockExpandCollapseCommand())
Return dock
End Function
Private Sub CreateSaveStateTrigger(ByVal dock As RadDock)
dock.AutoPostBack =
True
dock.CommandsAutoPostBack =
True
Dim saveStateTrigger As New AsyncPostBackTrigger()
saveStateTrigger.ControlID = dock.ID
saveStateTrigger.EventName =
"DockPositionChanged"
UpdatePanel1.Triggers.Add(saveStateTrigger)
saveStateTrigger =
New AsyncPostBackTrigger()
saveStateTrigger.ControlID = dock.ID
saveStateTrigger.EventName =
"Command"
UpdatePanel1.Triggers.Add(saveStateTrigger)
End Sub
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
Dim i As Integer = 0
While i < CurrentDockStates.Count
Dim dock As RadDock = CreateRadDockFromState(CurrentDockStates(i))
RadDockLayout1.Controls.Add(dock)
CreateSaveStateTrigger(dock)
System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
End While
End Sub
Protected Sub RadDockLayout1_LoadDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs)
For Each state As DockState In CurrentDockStates
e.Positions(state.UniqueName) = state.DockZoneID
e.Indices(state.UniqueName) = state.Index
Next
End Sub
Protected Sub RadDockLayout1_SaveDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs)
If save = True Then
CurrentDockStates = RadDockLayout1.GetRegisteredDocksState()
save =
False
End If
End Sub
Protected Sub ButtonAddDock_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim dock As RadDock = CreateRadDock()
RadDockZone1.Controls.Add(dock)
CreateSaveStateTrigger(dock)
save =
True
End Sub
End
Class
The AJAX Manager is not inside the DockZone.... What am I missing here? Thanks.
| <telerik:RadGrid ID="grid_applications" runat="server" |
| .... |
| <NestedViewTemplate> |
| <asp:Label ID="GridRec" runat="server" Visible="false" Text='<%# Eval("record") %>' /> |
| <uc1:AppViewer ID="AppViewer1" runat="server" /> |
| </NestedViewTemplate> |
| Protected Sub list_appState_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) |
| Dim record As Integer = (TryCast(Parent.FindControl("GridRec"), Label)).Text |
| Dim AppState As String = (TryCast(formview_AppInfo.FindControl("list_appState"), RadComboBox)).SelectedValue |
| Dim UpdateSuccess As Integer = Apps.UpdateAppState(record, AppState) |
| If UpdateSuccess > 0 Then |
| lbl_status.Text = String.Format("<br />The Application Status has been updated to '{0}' for record: {1}.<br /><br />", AppState, record) |
| Dim grid As RadGrid = (TryCast(Parent.FindControl("grid_applications"), RadGrid)) |
| grid.Rebind() |
| Else |
| End If |
| End Sub |
| switch (button.get_value()) { |
| case "AddInstance": |
| var treeview = $find("<%=RadTreeView1.ClientID %>"); |
| var treeNode = treeview.get_selectedNode(); |
| if (treeNode == null) { |
| alert("Select an application first"); |
| break; |
| }; |
| var application_id = treeNode.get_value(); |
| var arguements = "AddInstance," + application_id; |
| RadAjaxManager1.ajaxRequest(arguements); |
| break; |
| } |
|
Protected Sub RadAjaxManager1_OnAjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Dim splitArguements As Array = Split(e.Argument, ",") |
| Dim strFunction As String = splitArguements(0) |
| Dim intIndex As Integer = splitArguements(1) |
| Select Case strFunction |
| Case "AddInstance" |
| Dim hidden_idx As HtmlInputHidden = FindControl("hidden_idx") |
| SqlDataSource2.InsertParameters("instance_name").DefaultValue = "New Instance - " & CStr(Now) |
| SqlDataSource2.InsertParameters("application_id").DefaultValue = intIndex |
| SqlDataSource2.InsertParameters("testing_environment_id").DefaultValue = 1 |
| SqlDataSource2.Insert() |
| hidden_idx.Value = CStr(NewInstanceId) |
| RadGrid1.Rebind() |
| MsgBox(hidden_idx.Value) |
| End Select End Sub |
| Private Sub SqlDataSource2_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource2.Inserted |
| NewInstanceId = e.Command.Parameters("@instance_id").Value.ToString |
| End Sub |
| <body style="border:50px;"> |
| <form id="form1" runat="server"> |
| <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
| <script type="text/javascript"> |
| function RadAjaxManager1_OnResponseEnd(sender, args) { |
| var hidden_input = $find("<%=Hidden_idx.ClientID %>"); |
| alert(hidden_input); |
| var idx = hidden_input.value |
| alert(idx); |
| window.radopen("InstanceDetails.aspx?instance_id=" + instance_id, "RadWindow1"); |
| } |
| </script> |
| </telerik:RadCodeBlock> |
| <input type="hidden" id="Hidden_idx" name="Hidden_idx" runat="server" /> |
.RadGrid_Default
.rgRow,
.RadGrid_Default
.rgAltRow
{
padding-left:1px;
padding-right:1px;
font-size:11px;
cursor:default;
float:left;
display:block;
}
function ArchiveProjectGrid_RowDataBound(sender, args)
{
switch(MainTabSelected)
{
case Enum.MainTab.Archive:
args.get_item()._element.cells[0].innerHTML = ArchiveGridAltTemplate(sender,args).toString();
break;
}
function
ArchiveGridAltTemplate(sender,args)
{
var DataItem = args.get_dataItem();
var sb = new Sys.StringBuilder();
var panel = ReturnPanelFilter();
var items = panel.get_items();
var panelbar = ReturnPanelFilter();
var panelItem;
var panelItemAdd;
var panelToAddTo;
var strOne = DataItem["ProjectNo"] + "," + DataItem["ProjectLeader"]+ "," +DataItem["Client"]+ "," +DataItem["Study"]+ "," +DataItem["StartTime"]+ "," +DataItem["EndTime"]+ "," +DataItem["Dept"];
var rowIndex;
try{rowIndex = args.get_item()._element.rowIndex.toString()}
catch(sError) { rowIndex = args._element.rowIndex.toString()}
var myDate = DataItem["Date"];
var dt = new Date(myDate);
var newDate = dt.format("m/dd/yyyy");
var y=dt.getYear();
var m=dt.getMonth() + 1;
var day=dt.getDate();
newDate=m+
"/"+day+"/"+y ;
// var tempIndex = rowIndex;
// if(tempIndex >=18) {tempIndex = tempIndex - 18;}
// if(tempIndex != 0)
sb.appendLine(
"</td></tr></table>");
//class='GridRow' style=' height:150px;
sb.appendLine(
"<div style='width:290px;margin-top:0; height:150px; display:block;max-height:150px; position:relative; padding: 3px 5px 15px 8px;'>");
sb.appendLine(
"<div class='ThumbnilColumnExtLrg' style='float:left;margin-top:0;'>");
sb.appendLine(String.format(
"<img onload=\"RetrievePictureMedia(this,'{2}','s');\" title='{0}' ondblclick=\"SelectRowClickLaunch('{3}');\" onclick=\"SelectRowClick('{3}');\" alt='{1}' src=\"Images/EmptyMedia.jpg\" ></img>" , DataItem["ProjectNo"], DataItem["ProjectNo"], DataItem["ProjectNo"],rowIndex));
sb.appendLine(
"</div>");
sb.appendLine(
"<div class='AltTemplateItemCol' >");
sb.appendLine(
"<b>Project: </b>");
sb.appendLine(String.format(
"{0} <b><a style='color:red; cursor:pointer; font-size:8px;' onclick='LoadProjectITEMS({1})'>Details </a></b>",DataItem["ProjectNo"],rowIndex));
// sb.appendLine(String.format("{0}",DataItem["ProjectNo"]));
sb.appendLine(
"</div>");
sb.appendLine(
"<div class='AltTemplateItemCol' >");
sb.appendLine(
"<b>Date: </b>");
sb.appendLine(String.format(
"{0}",newDate));
sb.appendLine(
"</div>");
sb.appendLine(
"<div class='AltTemplateItemCol' >");
sb.appendLine(
"<b>Project Leader: </b>");
sb.appendLine(String.format(
"{0}",DataItem["ProjectLeader"]));
sb.appendLine(
"</div>");
sb.appendLine(
"<div class='AltTemplateItemCol' >");
sb.appendLine(
"<b>Expires in Days: </b>");
sb.appendLine(String.format(
"{0}",DataItem["ExpiresinDays"]));
sb.appendLine(
"</div>");
sb.appendLine(
"<div class='AltTemplateItemCol'>");
sb.appendLine(
"<b>City: </b>");
sb.appendLine(String.format(
"{0}",DataItem["City"]));
sb.appendLine(
"</div>");
sb.appendLine(
"</div>");
// if(tempIndex != (18 - 1))
sb.appendLine(
"</td><table style='display:none;'><tr><td>");
return sb;
}
<telerik:RadGrid ID="ArchiveProjectGrid" runat="server" EnableEmbeddedSkins="false"
EnableViewState="false" GridLines="None" ShowHeader="false" AllowPaging="true"
AllowCustomPaging="true" ShowFooter="true" AllowMultiRowSelection="false" Width="100%"
AutoGenerateColumns="false" ShowStatusBar="false" PageSize="3" Height="100%"
VirtualItemCount="500">
<StatusBarSettings ReadyText="" LoadingText="Please wait while processing your request" />
<MasterTableView ShowFooter="false" AllowFilteringByColumn="true" TableLayout="Fixed"
ClientDataKeyNames="ProjectNo,ItemID,ProjectLeader,Date,Facility,City,Study,ProjectTopic,Product,Dept,ExpiresinDays,ResearchVendor,Moderator,Name">
<Columns>
<telerik:GridBoundColumn DataField="ProjectNo" HeaderText="ProjectNo" Visible="true">
</telerik:GridBoundColumn>
</Columns>
<RowIndicatorColumn Visible="False" Display="false">
</RowIndicatorColumn>
<ExpandCollapseColumn Visible="False" Resizable="False">
</ExpandCollapseColumn>
<EditFormSettings>
<PopUpSettings ScrollBars="None"></PopUpSettings>
</EditFormSettings>
<HeaderStyle Wrap="False"></HeaderStyle>
</MasterTableView>
<FilterMenu BorderColor="Black">
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
</FilterMenu>
<PagerStyle Mode="NumericPages"></PagerStyle>
<SortingSettings SortedBackColor="Transparent" />
<ClientSettings AllowColumnsReorder="false" ReorderColumnsOnClient="false" AllowGroupExpandCollapse="false">
<Selecting AllowRowSelect="true" EnableDragToSelectRows="true" />
<Scrolling EnableVirtualScrollPaging="false" SaveScrollPosition="False" AllowScroll="true"
UseStaticHeaders="true" />
<ClientEvents OnRowDblClick="ArchiveProjectGrid_OnRowDblClick" OnRowSelected="ArchiveProjectGrid_OnRowClick"
OnDataBound="ArchiveProjectGrid_DataBound" OnGridCreated="ArchiveProjectGrid_Created"
OnCommand="ArchiveProjectGrid_Command" OnRowDataBound="ArchiveProjectGrid_RowDataBound" />
</ClientSettings>
</telerik:RadGrid>
i am getting this error The Controls collection cannot be modified because the control contains code blocks
i dont know what it means this is the code that i have changed to cause it
<
telerik:AjaxSetting AjaxControlID="RadMenu1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadMenu1" />
</UpdatedControls>
</telerik:AjaxSetting>