Page refreshed even after using Update Panel - AJAX - asp.net

I have a datalist where the huperlinks will be populated with list of article names. When clicking on any article link, i load the content inside tag with ID = "POST"
The problem is, when i click on the link in my datalist, the page refreshed to load the content. How can i solve this ? Thanks
<asp:ScriptManager ID="scm" runat="server">
</asp:ScriptManager>
<table>
<tr>
<td>
<asp:Panel ID="Panel1" runat="server" Width="800">
<div id="divContent" runat="server" class="post">
<table id="tblPost" style="float" border="1" style="border-style: outset; border-width: thin"
width="250" height="200" align="right">
<tr>
<td class="style2">
<asp:Label ID="Label1" runat="server" Width="200" Font-Bold="True" Text="Article Sections"></asp:Label>
</td>
</tr>
<tr>
<td align="left">
<asp:DataList ID="DLArticles" runat="server">
<ItemTemplate>
<table id="Table2" visible="true" align="left">
<tr align="left">
<td>
<asp:HyperLink ID="hypSubSections" runat="server" NavigateUrl='<%# "~/News.aspx?FID=" + DataBinder.Eval(Container.DataItem,"FID") + "&CID=" + DataBinder.Eval(Container.DataItem,"CID") %>'
Text='<%# DataBinder.Eval(Container.DataItem,"Title") %>'></asp:HyperLink>
</td>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
<tr>
<td align="right">
<asp:HyperLink ID="HypViewALL" runat="server">View All</asp:HyperLink>
</td>
</tr>
</table>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<p id="POST" runat="server">
</p>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DLArticles" />
</Triggers>
</asp:UpdatePanel>
</div>
</asp:Panel>
</td>
</tr>
</table>

First of all you need to use data-driven control that allows to use multiple key field names. DataList doesn't has such feature so you need to use GridView or ListView control. As each post idetified with unique combination of FID and CID values set those fields as DataKeyNames. Then, change HyperLink to LinkButton control and set appropriate CommandName property value. After that you need to register each LinkButton as AsyncPostback control (on a page, not in UpdatePanel1's triggers collection) or just wrap whole ListView by an UpdatePanel. Then all you need is to handle SelectedIndexChanged event and update post content.
<asp:UpdatePanel runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<asp:ListView runat="server" ID="ListView1" DataKeyNames="FID,CID">
<LayoutTemplate>
<table>
<asp:PlaceHolder runat="server" ID="itemPlaceholder" />
</table>
</LayoutTemplate>
<ItemTemplate>
<tr style="text-align: left;">
<td>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Select" Text='<%# Eval("Title") %>' />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<p runat="server" id="POST">
</p>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ListView1" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
private static readonly List<Post> DataSource = new List<Post>
{
new Post{FID = 1, CID = "1", Title="First", Content= Guid.NewGuid().ToString()},
new Post{FID = 2, CID = "1", Title="Second", Content= Guid.NewGuid().ToString()},
new Post{FID = 1, CID = "2", Title="Third", Content= Guid.NewGuid().ToString()},
new Post{FID = 2, CID = "2", Title="Fourth", Content= Guid.NewGuid().ToString()},
};
protected void Page_Init(object sender, EventArgs e)
{
ListView1.SelectedIndexChanging += ListView1_SelectedIndexChanging;
ListView1.SelectedIndexChanged += ListView1_SelectedIndexChanged;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ListView1.DataSource = DataSource;
ListView1.DataBind();
}
}
void ListView1_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
{
ListView1.SelectedIndex = e.NewSelectedIndex;
}
void ListView1_SelectedIndexChanged(object sender, EventArgs e)
{
var dataKey = ListView1.SelectedDataKey;
var fid = (int)dataKey["FID"];
var cid = dataKey["CID"] as string;
var post = DataSource.FirstOrDefault(p => p.FID == fid && p.CID == cid);
if (post != null)
{
POST.InnerText = Server.HtmlEncode(post.Content);
}
}
public class Post
{
public int FID { get; set; }
public string CID { get; set; }
public string Title { get; set; }
public string Content { get; set; }
}

Related

get the value of all the checked checkboxes on button click

I have created a table in my .aspx file that looks like this:
Here is the code that does this:
<!-- code for generating the "add selected sessions" button -->
<table>
<tr>
<td><strong>Individual Sessions</strong></td>
<td >
<div class="addButton" style="text-align: center;">
<asp:LinkButton ID="LinkButton2" runat="server" Text="Add Selected Sessions" OnClick="btnAddToCart_Click" />
</div>
</td>
</tr>
</table>
<!-- add all the sessions for the user to select -->
<asp:Repeater ID="rptFeesSession" runat="server">
<HeaderTemplate>
<table >
</HeaderTemplate>
<ItemTemplate>
<asp:HiddenField ID="hdnIsSession" runat="server" Value='<%#Eval("isSession")%>' />
<tr runat="server" visible='<%# Eval("isSession")%>'>
<td valign="top" colspan="2" style="position: relative;">
<asp:HyperLink CssClass="siteColorFG popBtn" ID="hlFeeType" runat="server" Text='<%#Eval("title")%>' NavigateUrl="javascript:;"/>
</td>
<td valign="top">
<div class="">
<asp:CheckBox ID="LinkButton3" CommandArgument='<%#Eval("id")%>'CssClass="checkB" OnClick="btnAddToCart_Click" runat="server" Text='<%#Eval("amount", "{0:C}")%>' />
</div>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
In my code behind file i want to capture all the checkboxes that have been checked and their respective CommandArgument values.
protected void btnAddToCart_Click(object sender, EventArgs e)
{
using (MyEntities db = new MyEntities())
{
//button was clicked. fetch all the check boxes from the rptFeesSession repeater into an int[]
}
}
There are several issues in your code (including conceptual / logic)
Item events in a Repeater should address item related things.
Click event handler has no access to CommandArgument attribute. Use Command instead.
Checkbox control doesn't support onclick event.
Checkbox events can run immediately only when there is AutoPostback="true".
If you want to refresh all repeater data on change of any checkbox then you can do something like this.
<asp:ScriptManager runat="server" ID="scriptMgr" /><%-- Strongly recommended --%>
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Repeater ID="rptFeesSession" runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<asp:HiddenField ID="hdnIsSession" runat="server" Value='<%#Eval("isSession")%>' />
<tr runat="server" visible='<%# Eval("isSession")%>'>
<td colspan="2" style="position: relative;">
<asp:HyperLink CssClass="siteColorFG popBtn" ID="hlFeeType" runat="server" Text='<%#Eval("title")%>' NavigateUrl="javascript:;" />
</td>
<td>
<div class="">
<asp:HiddenField runat="server" ID="hidID" Value='<%#Eval("id") %>' />
<asp:CheckBox ID="LinkButton3"
AutoPostBack="true" CssClass="checkB"
OnCheckedChanged="LinkButton3_CheckedChanged" runat="server"
Text='<%#Eval("amount", "{0:C}")%>' />
</div>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
//.cs
protected void LinkButton3_CheckedChanged(object sender, EventArgs e)
{
decimal total = 0;
using (MyEntities db = new MyEntities())
{
foreach (RepeaterItem item in rptFeesSession.Items)
{
var chk = item.FindControl("LinkButton3") as CheckBox;
if(chk!=null && chk.Checked){
string id = (item.FindControl("hidID") as HiddenField).Value;
total += decimal.Parse(chk.Text);
//do stuff
}
}
}
}

Add UserControl Dynamically in Panel Control asp.net page

I am creating a website where user gives some value in textbox and clicks a button.
On the button click the UserControl should be added for number of time the user has given input.
What I did is,
protected void btnSearchTaxi_Click(object sender, EventArgs e)
{
for (int i = 0; i < 4; i++)
{
CustomDisplayList cus = new CustomDisplayList();
cus.ID = "cus" + i;
cus.Visible = true;
pnlSearchResult.Controls.Add(cus);
}
}
CustomDisplayList is my user control which is complex control [mixture of labels, textbox, button].
<td style="width:20%; font-family: Century Gothic; font-size:12px; color:White; text-
align:center;">Click to find<br/>
<asp:Button ID="btnSearchTaxi" runat="server" Text="Search Taxi" CssClass="googleButton"
Width="200px" onclick="btnSearchTaxi_Click" />
</td>
<td style="height:150px; width:100%; background-color: #FF6600">
<table style="height:100%; width:100%">
<tr><td style="color:White; font-size:30px; ">Search Result :</td></tr>
<tr><td><asp:Panel ID="pnlSearchResult" runat="server"></asp:Panel>
</td></tr>
</table>
</td>
The code was executed without any error, but the Control was not generated inside the panel.
Now I have changed the CODE to something like
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode = "Conditional" >
<ContentTemplate>
<asp:Button ID="btnSearchTaxi" runat="server" Text="Search Taxi" CssClass="googleButton" Width="200px" onclick="btnSearchTaxi_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode = "Conditional">
<ContentTemplate>
<asp:Panel ID="pnlSearchResult" runat="server" Width="100%" Height="200px" BackColor="Aquamarine"></asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID = "btnSearchTaxi" EventName="Click"/>
</Triggers>
</asp:UpdatePanel>
But the still the Dynamic usercontrol are not getting created.

how to pass a variable to a user control to be used as selectcommand of sqldatasource

I don't understand why a property ParentScheduleItemId in my usercontrol is always zero. All I want to do is pass a value to my user control so that it can be used as a selectparameter of a selectcommand in a SqlDataSource. I have the following code below, which seems to cause ParentScheduleItemId == 0, but it actually prints the expected non-zero value that I passed it in the ascx file right beside the sentence No data was returned:
namespace CCApplication.Cms
{
public partial class schedule_sub_item : System.Web.UI.UserControl
{
public int ParentScheduleItemId {
get;
set; }
protected void Page_Load(object sender, EventArgs e)
{
SqlDataSource1.SelectParameters.Add("ParentScheduleItemId", ParentScheduleItemId.ToString());
//SqlDataSource1.SelectParameters.Add("ParentScheduleItemId", "12");
}
}
}
I have the following code in the ascx file
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NewConferencesApplicationConnectionString %>"
SelectCommand="
SELECT [ScheduleItemId],[ParentScheduleItemId],[Name],[Type],[Location],[MaximumUsers],[CompanionAllowed],[StartTime],[EndTime]
FROM [Conferences_ScheduleItem]
WHERE ParentScheduleItemId = #ParentScheduleItemId
ORDER BY StartTime;
"
DeleteCommand="DELETE FROM [Conferences_ScheduleItem] WHERE [ScheduleItemId] = #ScheduleItemId"
>
</asp:SqlDataSource>
<asp:ListView ID="ListView1" runat="server" DataKeyNames="ScheduleItemId"
DataSourceID="SqlDataSource1">
<EmptyDataTemplate>
<table id="Table1" runat="server" style="">
<tr>
<td>
No data was returned.<% Response.Write(ParentScheduleItemId.ToString()); %></td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<tr style="">
<td>
<asp:Label ID="ScheduleItemIdLabel" runat="server"
Text='<%# Eval("ScheduleItemId") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table id="Table2" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="0" style="">
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="Tr3" runat="server">
<td id="Td2" runat="server" style="">
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
So all I want to do is do something like <usercontrol:mylistview ParentScheduleItemId=24> and then for 24 to be used as part of my SelectCommand. How do I achieve this?
Note - you'll notice that I commented out the line SqlDataSource1.SelectParameters.Add("ParentScheduleItemId", "12"); . If i uncomment it, it actually behaves as expected, and gives the number 12 to my select parameters and the sqldatasource gives me the values I want. I just don't understand why the line above it has a ParentScheduleItemId == 0. Does this have something to do with the page load cycle? Anyway, i just want to pass the right parentscheduleitemid to my select command.
Ok that was frustrating. I found the solution after 3 hours of banging my head against the wall. Here's the working code:
// codebehind
namespace CCApplication.Cms
{
public partial class schedule_sub_item : System.Web.UI.UserControl
{
public string _parentScheduleItemId;
public string ParentScheduleItemId {
get
{
return _parentScheduleItemId;
}
set
{
_parentScheduleItemId = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void UpdateSqlParametersEventHandler(object sender, SqlDataSourceSelectingEventArgs e)
{
System.Data.Common.DbParameter param = e.Command.CreateParameter();
param.ParameterName = "#ParentScheduleItemId";
param.Value = this._parentScheduleItemId;
e.Command.Parameters.Add(param);
}
}
}
//frontend code
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NewConferencesApplicationConnectionString %>"
OnSelecting="UpdateSqlParametersEventHandler"
SelectCommand="
SELECT [ScheduleItemId],[ParentScheduleItemId],[Name],[Type],[Location],[MaximumUsers],[CompanionAllowed],[StartTime],[EndTime]
FROM [Conferences_ScheduleItem]
WHERE ParentScheduleItemId = #ParentScheduleItemId
ORDER BY StartTime;
"
DeleteCommand="DELETE FROM [Conferences_ScheduleItem] WHERE [ScheduleItemId] = #ScheduleItemId"
>
</asp:SqlDataSource>
<asp:ListView ID="ListView1" runat="server" DataKeyNames="ScheduleItemId"
DataSourceID="SqlDataSource1">
<EmptyDataTemplate>
<table id="Table1" runat="server" style="">
<tr>
<td>
No data was returned.<% Response.Write(ParentScheduleItemId.ToString()); %></td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<tr style="">
<td>
<asp:Label ID="ScheduleItemIdLabel" runat="server"
Text='<%# Eval("ScheduleItemId") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table id="Table2" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="0" style="">
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="Tr3" runat="server">
<td id="Td2" runat="server" style="">
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
So basically I needed to add a OnSelecting="UpdateSqlParametersEventHandler", then add that function in the code behind to set the parameter.
The reason i was having problems before was because the page load cycle was causing the sqldatasource to run before the ParentScheduleItemId was even being set ...

Drag Drop items within ListView in ASP.Net

I have a listview showing images like ImageViewer and I want to implement Drag-Drop behavior within ListView. Please let me know how can i achieve the Srag-Drop inside the below kind of customized ListView.
<asp:ListView ID="lvPhotoViewer" runat="server" GroupItemCount="3" InsertItemPosition="LastItem">
<LayoutTemplate>
<table id="groupPlaceholderContainer" runat="server" border="1">
<tr id="groupPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<td id="Td4" align="center" style="background-color: #eeeeee;">
<asp:Image runat="server" ID="imPhoto" Height="100px" Width="100px" ImageUrl='<%# "~"+Eval("PhotoUrl") %>' />
<br />
<asp:Label ID="DefaultPhotIDLabel" runat="server" Text='<%# Eval("PhotoName") %>' />
</td>
</ItemTemplate>
<GroupTemplate>
<tr id="itemPlaceholderContainer" runat="server">
<td id="itemPlaceholder" runat="server">
</td>
</tr>
</GroupTemplate>
<InsertItemTemplate>
<td id="Td3" width="150px" height="150px" runat="server" align="center" style="background-color: #e8e8e8;
color: #333333;">
<asp:FileUpload ID="fileUpload" runat="server" />
</td>
</InsertItemTemplate>
</asp:ListView>
Code Behind:
public class ImageEntity
{
public string PhotoName { get; set; }
public int PhotoIndex { get; set; }
public string PhotoURL { get; set; }
}
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
IList<ImageEntity> imagesList = new List<ImageEntity>()
{
new ImageEntity(){ PhotoName="House1", PhotoIndex=1, PhotoURL= #"\Images\House-01.JPG" },
new ImageEntity(){ PhotoName="House2", PhotoIndex=2, PhotoURL= #"\Images\House-05.JPG" },
new ImageEntity(){ PhotoName="House3", PhotoIndex=3, PhotoURL= #"\Images\house.jpg" },
new ImageEntity(){ PhotoName="House4", PhotoIndex=4, PhotoURL= #"\Images\house2.jpg" }
};
lvPhotoViewer.DataSource = imagesList;
lvPhotoViewer.DataBind();
}
}
Please suggest me a way to implement the drag-drop for images within the ListView
Consider using the JQuery drag/drop UI feature: http://jqueryui.com/demos/draggable/ and http://jqueryui.com/demos/droppable/.
Also, if you want to drag/drop rows, check this out: jQuery draggable table elements
HTH.

Problem with ajax and RadTreeView

Hi all :
I have a user control which contain RadTreeView from Telerik inside ModalPopupExtender , the previous control loaded at runtime :
DashBoardDesignerCell tempCell = LoadControl("~/UserControls/DashBoardDesignerControls/DashboardDesignerCell.ascx") as DashBoardDesignerCell;
When SelectedNodeChanged occurs the ModalPopupExtender disappears.
This is the full code for user contrl:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="DashBoardDesignerCell.ascx.cs"
Inherits="RightBI.UserControls.DashBoardDesignerControls.DashBoardDesignerCell" %>
<%# Register Src="~/UserControls/PresentationControls/SelectPresentationControl.ascx" TagPrefix="rightbicontrols" TagName="selectpresentationcontrol" %>
<asp:UpdatePanel ID="dashboardDesignerCellUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table cellpadding="3" cellspacing="0" style='width: 100%; border-style: solid; border-width: thin;
border-color: Silver;'>
<thead>
<tr style='background: blue'>
<td>
<asp:ImageButton SkinID="selectControlButton" runat="server" ID="addControlButton"
OnClick="okButton_Click" />
<asp:ImageButton SkinID="deleteControlButton" runat="server" ID="removeControlButton"
OnClick="removeControlButton_Click" />
<asp:LinkButton runat="server" ID="LinkButton1" Style='display: none;'>
</asp:LinkButton>
<ajax:ModalPopupExtender runat="server" TargetControlID="addControlButton" ID="selectPresentationControlModalPopupExtender"
PopupControlID="popupSelectPresentationControl" CancelControlID="cancelButton"
BackgroundCssClass="popup_black_BG">
</ajax:ModalPopupExtender>
<asp:Panel runat="server" ID="popupSelectPresentationControl" Style='display: none;'>
<asp:UpdatePanel runat="server" ID="popupSelectUpdatePanel" UpdateMode="Conditional">
<ContentTemplate>
<div class="popup_container">
<table cellpadding="0" cellspacing="0" class="popup_table">
<tr>
<td class="popup_header_left">
</td>
<td class="popup_header_middle">
</td>
<td class="popup_header_right">
</td>
</tr>
<tr>
<td class="popup_main_left">
</td>
<td class="popup_main">
<div class="popup_content">
<table cellpadding="0" cellspacing="0" style='width: 100%'>
<tr>
<td>
<span>Caption (*):</span>
</td>
<td>
<asp:TextBox runat="server" ID="captionTextBox">
</asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="captionTextBox"
ValidationGroup="SelectPresentationControl" ErrorMessage="Caption is required."
Text="*">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="2">
<rightbicontrols:selectpresentationcontrol id="selectControl" runat="server" />
</td>
</tr>
<tr>
<td colspan="2">
<telerik:RadButton ID="okButton" Text="Save" SkinID="okButton" runat="server" CommandName="Save"
ValidationGroup="SelectPresentationControl" OnClick="okButton_Click">
</telerik:RadButton>
<telerik:RadButton ID="cancelButton" Text="Cancel" SkinID="cancelButton" runat="server"
CommandName="Cancel">
</telerik:RadButton>
</td>
</tr>
</table>
</div>
</td>
<td class="popup_main_right">
</td>
</tr>
<tr>
<td class="popup_footer_left">
</td>
<td class="popup_footer_middle">
</td>
<td class="popup_footer_right">
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</td>
</tr>
</thead>
<tbody>
<tr>
<td style='min-height: 150px;'>
<asp:UpdatePanel runat="server" ID="controlUpdatePanel" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel runat="server" ID="controlPanel">
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</tbody>
</table>
</ContentTemplate>
</asp:UpdatePanel>
public Guid DashboardColumnID
{
get
{
if (ViewState["DashboardColumnID"] == null)
{
return Guid.Empty;
}
return new Guid(ViewState["DashboardColumnID"].ToString());
}
set
{
ViewState["DashboardColumnID"] = value;
}
}
protected Guid DashboardZoneID
{
get
{
if (ViewState["DashboardZoneID"] == null)
{
return Guid.Empty;
}
return new Guid(ViewState["DashboardZoneID"].ToString());
}
set
{
ViewState["DashboardZoneID"] = value;
}
}
protected Guid PresentationControlID
{
get
{
if (ViewState["PresentationControlID"] == null)
{
return Guid.Empty;
}
return new Guid(ViewState["PresentationControlID"].ToString());
}
set
{
ViewState["PresentationControlID"] = value;
}
}
protected void LoadDashboardZone()
{
DashboardColumn dashboardColumn = DashboardColumn.GetDashboardColumn(DashboardColumnID);
if (dashboardColumn.DashboardZones.Count == 1)
{
DashboardZoneID = dashboardColumn.DashboardZones.FirstOrDefault().Id;
}
if (DashboardZoneID == Guid.Empty)
{
removeControlButton.Visible = false;
addControlButton.Visible = true;
}
else
{
removeControlButton.Visible = true;
addControlButton.Visible = false;
}
controlPanel.Controls.Clear();
if (DashboardZoneID != Guid.Empty)
{
DashboardDesignerZone zone = LoadControl("~/UserControls/DashBoardDesignerControls/DashboardZone.ascx") as DashboardDesignerZone;
zone.DashboardZoneID = DashboardZoneID;
controlPanel.Controls.Add(zone);
}
controlUpdatePanel.Update();
}
protected void Page_Load(Object sender, EventArgs e)
{
//
String code = "function openWindow() {var oWnd = $find('" + selectPresentationWindow .ClientID+ "');oWnd.show(); }";
ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "OpenRadWindow", code , true);
LoadDashboardZone();
}
protected void okButton_Click(object sender, EventArgs e)
{
AddPresentationControl(captionTextBox.Text, selectControl.PresentationControlId);
//dashboardDesignerCellUpdatePanel.Update();
}
protected void removeControlButton_Click(Object sender, EventArgs e)
{
if (DashboardZone.RemoveDashboardZone(this.DashboardZoneID))
{
PresentationControlID = Guid.Empty;
DashboardZoneID = Guid.Empty;
LoadDashboardZone();
//dashboardDesignerCellUpdatePanel.Update();
}
}
public void AddPresentationControl(String caption, Guid presentationControlID)
{
DashboardZone tempDashboardZone = DashboardZone.AddDashboardZone(caption, DashboardColumnID, presentationControlID);
if (tempDashboardZone != null)
{
PresentationControlID = presentationControlID;
DashboardZoneID = tempDashboardZone.Id;
LoadDashboardZone();
}
}
Is There any idea???
Do you by any means do postback or ajax request when a treeview node is selected? This might be potential cause the modal popup extender is closed. Why you do not use the Telerik Ajax window instead, to compare the results? Also I assume that you load the user control dynamically on init or load of the page and clear the Controls collection of the container before adding the user control inside it.

Resources