"Preview Area" in UpdatePanel not Refreshing - asp.net

Greetings!
I have a "code builder" page where users select various radio buttons and it generate HTML markup (mostly SCRIPT tags) that they can use on their page to display some data. There is also a "preview" area so they can see the results before they copy/paste the code in their site. The form exists in a FormView control and is wrapped by an UpdatePanel like so:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:FormView ID="FormView1" runat="server" DataSourceId="XmlDataSource1">
<ItemTemplate>
<div id="configArea">
<ul>
<li>
<%# XPath("Steps/Step1/ServerStatus") %><br />
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="OneA" Checked="true" AutoPostBack="true" Text='<%# XPath("Steps/Step1/YesOption") %>' />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="OneA" AutoPostBack="true" Text='<%# XPath("Steps/Step1/NoOption") %>' />
</li>
<li>
<%# XPath("Steps/Step1/Uptime") %><br />
<asp:RadioButton ID="RadioButton3" runat="server" GroupName="OneB" Checked="true" AutoPostBack="true" Text='<%# XPath("Steps/Step1/YesOption") %>' />
<asp:RadioButton ID="RadioButton4" runat="server" GroupName="OneB" AutoPostBack="true" Text='<%# XPath("Steps/Step1/NoOption") %>' />
</li>
<li>
<%# XPath("Steps/Step1/IPAddress") %><br />
<asp:RadioButton ID="RadioButton5" runat="server" GroupName="OneC" Checked="true" AutoPostBack="true" Text='<%# XPath("Steps/Step1/YesOption") %>' />
<asp:RadioButton ID="RadioButton6" runat="server" GroupName="OneC" AutoPostBack="true" Text='<%# XPath("Steps/Step1/NoOption") %>' />
</li>
</ul>
</div>
<div id="copyCode">
<%# XPath("Steps/Step2/CopyPasteCode") %><br />
<asp:TextBox ID="Textbox1" runat="server" TextMode="MultiLine" Width="300" Height="300" />
</div>
<div id="previewArea">
<%# XPath("Steps/Step3/PreviewTitle") %><br />
<asp:Literal ID="Literal1" runat="server" />
</div>
</ItemTemplate>
</asp:FormView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" XPath="Root/Data" />
It successfully generates the code in the copycode TextBox (TextBox1), which may look something like this:
<script src="http://example.com/src/Constants.js"></script>
<script>
showIPAddress = 0;
DisplayServerStatus();
</script>
At the same time, I update the "preview" area's Literal control (Literal1) with the text from the copycode TextBox (TextBox1). The preview is displayed perfectly when not inside an UpdatePanel, but does not work when it is (and I'd prefer to use an UpdatePanel to prevent page refreshing). I do the update of the "preview" area and copycode text during the PreRender event:
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
UpdateCodeSnippetAndPreviewArea();
}
Any ideas why the preview doesn't update when it's in an UpdatePanel?

The reason it is not updating when using an UpdatePanel is that the ASP .NET AJAX framework does not process any inline javascript returned by the server. Look at using the ScriptManager.RegisterStartUpScript method on the server side to register execution of inline javascript. Essentially you could use this method to initiate execution of custom javascript once the panel is updated. In your case, your custom javascript would need to interpret the preview script appropriately (i.e. detect script tags, register them dynamically then execute the given functions).
Hope this helps!
Rohland

Related

Required Field Validator hidden in asp.net Repeater

I have reapeater in my code and trying to validate the textbox using asp.net required field validator. But validation messsage
not displaying, i opened the developer tools and found that style="visibility:hidden" added into the required field validator.
Below is my code
<asp:Repeater ID="RepeaterCategory" runat="server" DataSource='<%# this.Categories.Count==0 ? null : this.Categories %>'>
<ItemTemplate>
<div>
<asp:Label runat="server" Visible="true" Text="Category" />
<asp:PlaceHolder runat="server" Visible="true">
<asp:TextBox ID="txtCategoryID" runat="server" value="1" />
<asp:TextBox ID="txtCategoryName" runat="server" value="<%# (Container.DataItem as Category).Name %>" />
<asp:RequiredFieldValidator runat="server" ErrorMessage="<br/>This is a required field" ControlToValidate="txtCategoryName" ValidationGroup="NewCategoryGroup"></asp:RequiredFieldValidator>
</asp:PlaceHolder>
<asp:LinkButton runat="server" ToolTip="Save" ValidationGroup="NewCategoryGroup" OnClick="SaveCategory_Click"><img src='<%# some path%>/images/save.gif' /></asp:LinkButton>
<asp:LinkButton runat="server" ToolTip="Close" OnClick="CloseCategory_Click"></asp:LinkButton>
</div>
</ItemTemplate>
</asp:Repeater>
Code behind file
protected void SaveCategory_Click(object o, EventArgs e)
{
Page.Validate("NewCategoryGroup");
if (!Page.IsValid)
return;
//logic
}
Can anyone suggest how to enable it?
The style="visibility:hidden" is default behavior. It changes to style="visibility: visible;" when the error message needs displaying. Therefore you probably don't have an error.
The validator is a 'RequiredFieldValidator', and since the textbox that is being validated is already filled with the value "TestCategory" there are no errors. If you just add text to the Save button (which has no ID tag) so that it becomes visible, remove the value from the txtCategoryName textbox and click the save button you will see the error message.
This works:
<asp:TextBox ID="txtCategoryName" runat="server" value="" />
<asp:RequiredFieldValidator runat="server" ErrorMessage="<br/>This is a required field" ControlToValidate="txtCategoryName" ValidationGroup="NewCategoryGroup"></asp:RequiredFieldValidator>
<asp:LinkButton runat="server" ToolTip="Save" ValidationGroup="NewCategoryGroup" OnClick="SaveCategory_Click" ID="LinkButton1">Save Me!</asp:LinkButton>
You don't need this code
Page.Validate("NewCategoryGroup");
if (!Page.IsValid)
Another advantage is that the validators work now without a postback, this saves a roundtrip to the server.
And ALWAYS do server side validation also, but try to do the first validation without postback.
UPDATE
What you want is probably validation per item. And since your validationgroup is always the same it will fire for all textboxes. Try this:
<asp:Repeater ID="RepeaterCategory" runat="server">
<ItemTemplate>
<div>
<asp:TextBox ID="txtCategoryName" runat="server" ValidationGroup='<%# "myVal_" + Container.ItemIndex %>' Text='<%# Eval("Category") %>' />
<br />
<asp:RequiredFieldValidator runat="server" Display="Dynamic" ErrorMessage="This is a required field<br />" ControlToValidate="txtCategoryName" ValidationGroup='<%# "myVal_" + Container.ItemIndex %>'></asp:RequiredFieldValidator>
<asp:LinkButton runat="server" ValidationGroup='<%# "myVal_" + Container.ItemIndex %>' OnClick="Button1_Click" ID="LinkButton1">Save Me!</asp:LinkButton>
</div>
</ItemTemplate>
</asp:Repeater>

Alternative to Postback on asp.net page

I am looking for an alternative where user doesnt has to wait for postback in an asp.net page.
My situation :
I have several drop down lists on my asp.net page (11 infact) and I have a checkbox. 2 drop downs are cascading. i.e. selecting 1st drop down changes the 2nd drop down contents. I have a new option in some of the dropdowns (6 drop downs). If user chooses this option then a text box shows up with a "Add" button. Adding text to that text box and hitting "Add" adds the new value to the drop down and disappears this textbox and the button. So is it possible for using a non postback option but have the same situation going on? User does not like that the page postbacks 11 times. What is my alternative? If you need more information, please ask. Thanks
EDIT:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddlCustomerContact" runat="server" DataTextField="FullName" DataValueField="Customers_SourceIDfk2" AutoPostBack="true" TabIndex="1" />
</ContentTemplate>
</asp:UpdatePanel>
Protected Sub ddlCustomerContact_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlCustomerContact.SelectedIndexChanged
If ddlCustomerContact.SelectedIndex = 1 Then
divAddNewCustomerContact.Visible = True
Else
divAddNewCustomerContact.Visible = False
End If
End Sub
Your only real option if you don't want standard postbacks would be AJAX. There are numerous frameworks available, so you can use the Microsoft framework (bundled in 3.5+) or jQuery (also bundled in VS 2010+, I believe).
There are other frameworks available, but those two are going to be the most tightly integrated. Other frameworks will require a little more work to implement.
This is how I use an update panel for a widget that I created.
<asp:DropDownList ID="ddlPayrollStores" runat="server" OnSelectedIndexChanged="ddlPayrollStores_SelectedIndexChanged" AutoPostBack="true">
</asp:DropDownList>
<asp:UpdatePanel ID="UpdatePanelPayroll" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlPayrollStores" EventName="SelectedIndexChanged"></asp:AsyncPostBackTrigger>
</Triggers>
<ContentTemplate>
<div class="dragbox-content">
<asp:Label ID="lblLabelHours" runat="server" Text="Reg Hours: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalHours" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lblLabelOverTime" runat="server" Text="Total Overtime Hours: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalOvertime" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lblLabelHoliday" runat="server" Text="Total Holiday: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalHoliday" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lblLabelVacation" runat="server" Text="Total Vacation: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalVacation" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lbllableTotalHours" runat="server" Text="Total Hours: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalStoreHours" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lblLabelPay" runat="server" Text="Total Pay: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalPay" runat="server" Text=""></asp:Label>
<br />
<br />
<div style="align-content: center">
<asp:LinkButton ID="lbDetailed" runat="server" Text="Detailed Report" PostBackUrl="~/Reporting/Payroll/StorePayroll.aspx"></asp:LinkButton>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
This is for a payroll widget that shows the store's total payroll. So when I select which store I want to see with the drop down, the update panel will post back without posting back the entire page. In my case, it will just display numbers as labels. Hopefully this leads you in the right direction and possibly clears it up a bit.

button in updatepanel content template not firing

Hi I have placed some code in an updatepanel on a web page and all works fine except for one button. Whats displayed in the updatepanel is just a number of items that a user has added to a shopping cart.
The buttons that work are btnPlus and btnMinus, they increase the quantity of an item in a shopping cart, and in their code behind this updates the quantities that are being stored in the database.
What's not working is the btnDelete - this is supposed to delete the item from the shopping cart.
When I click it nothing happens - but what's really strange(at moment) is that it does work after I click after I click btnPlus or btnMinus.
Any ideas?
<asp:UpdatePanel ID="pnlSmallCheckout" runat="server">
<ContentTemplate>
<div class="basket">
<%Dim SmallCounter as integer = 0 %>
<asp:Repeater ID="rptSmallCheckout" runat="server">
<ItemTemplate>
<div class="item">
<div class="image">
<img src="/graphics/placeholders/sweets.jpg">
</div>
<div class="title">
<%#Eval("PTitle")%> x<span class="amount" id="span_small_<%=SmallCounter%>"><%#Eval("Quantity") %></span><asp:TextBox ID="txtQuantity" runat="server" Text='<%# Eval("Quantity") %>' MaxLength="3" Style="display: block"></asp:TextBox>
<asp:TextBox ID="txtSmallNumKilos" runat="server" Style="display: block"></asp:TextBox>
<asp:Literal ID="ltrSmallNumKilos" runat="server" Visible="false"></asp:Literal>
</div>
<div class="controls">
<asp:Button ID="btnMinus" CssClass="button minus" Text="-" runat="server" CommandName='<%# Eval("ItemID") %>' OnClientClick="if (!update_qty('minus',this)) return false;" OnClick="btnUpdate_Click" />
<asp:Button ID="btnPlus" CssClass="button plus" Text="+" runat="server" CommandName='<%# Eval("ItemID") %>' OnClientClick="if (!update_qty('plus',this)) return false;" OnClick="btnUpdate_Click" />
<asp:Button ID="btnDelete" runat="server" Text="x" CssClass="button remove" CommandName='<%# Eval("ItemID") %>' OnClientClick="update_total(this);" OnClick="btnDelete_Click" />
</div>
</div>
<%SmallCounter=SmallCounter+1 %>
</ItemTemplate>
</asp:Repeater>
<!-- item -->
</div>
</ContentTemplate>
<Triggers>
</Triggers>
</asp:UpdatePanel>
Any ideas?
Are you getting any javascript error? Check using firebug / other tools?
Errors might be interfering with the updatepanel postback event.
not need to return the clientSidefunction otherwise the serverSide will not fire
OnClientClick="return update_total(this);" OnClick="btnDelete_Click"
ensure "update_total()" "returns true;" if you want to postback.

How to set a download counter on Hyperlink Control inside Repeater? asp.net

I have a hyperlink inside a repeater control for the list of pdf. I want to set a download counter on each click on each hyperlink. The FileName must be a parameter. My code is basically like below. There is also code that calls stored procedure and bind it to the repeater on page_load.
<asp:Repeater ID="rptPDF" runat="server">
<ItemTemplate>
<div class="repeaterResources">
<b><%# Eval("Name") %></b><br />
<b>Description</b> <%# Eval("Description") %><br />
<asp:HyperLink ID="HyperLink2" runat="server" class="downloadLink" NavigateUrl='<%# "~/PDF/" & Eval("Filename") %>' Target="_blank">Download</asp:HyperLink><br /><br />
</div>
</ItemTemplate>
</asp:Repeater>
The mystery bit is how to get a button click event from here. Thanks.
You can use the OnCommand event and set the CommandArgument attribute with a value using
<%# Eval('myvalue') %>.
MSDN has an example minus the repeater: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.oncommand.aspx
Sample:
<asp:Repeater ID="repeater" runat="server">
<ItemTemplate>
<asp:LinkButton runat="server" ID="button1" OnCommand="button1_command" CommandArgument='<%# Eval("myvalue") %>' />
</ItemTemplate>
</asp:Repeater>

ASP.NET panel does not update when last item gets deleted

I am sure that I am missing something really obvious here, but I just can't see it.
I have an update panel with a datalist inside it. Each item of the datalist has a delete button with which I issue the Delete command for the item.
Deletion is a two part process: I first pop up a modal dialogue from codebehind to ask for confirmation, like so:
/// <summary>
/// Manager delete command
/// </summary>
protected void dlKeywordsManager_DeleteCommand(object source, DataListCommandEventArgs e)
{
//Get the subject ID
int keywordID = (int)dlKeywordsManager.DataKeys[e.Item.ItemIndex];
//Remember the keyword ID on the modal popup
hfKeywordID.Value = keywordID.ToString();
btnConfirmationPopupOK.CommandArgument = "Delete";
lblConfirmationPopupMessage.Text = "キーワード「" + e.CommandArgument.ToString() + "」を本当に削除しますか?";
mpConfirmationPopup.Show();
dlKeywordsManager.DataBind();
udpKeywordsManager.Update();
}
This modal popup is also within the update panel so that I can get the label text values refreshed on partial postback.
When the use presses the OK button of the popup I go on to execute:
protected void btnConfirmationPopupOK_Click(object source, EventArgs e)
{
int keywordID = int.Parse(hfKeywordID.Value);
KeywordBLLOperation operationResult;
switch (((Button)source).CommandArgument)
{
case "Delete":
operationResult = keywordsAPI.DeleteKeyword(keywordID);
switch (operationResult.Result)
{
case KeywordBLLOperationResult.Deleted:
lnlNotificationsPopupMessage.Text = "キーワード「" + operationResult.KeywordName + "」を削除しました。";
break;
case KeywordBLLOperationResult.Failed:
lnlNotificationsPopupMessage.Text = "キーワード「" + operationResult.KeywordName + "」の削除に失敗しました。アドミニストレーターにお伝えください。";
break;
}
break;
}
mpNotificationPopup.Show();
dlKeywordsManager.DataBind();
udpKeywordsManager.Update();
}
I have remove a few non-essential lines here for brevity.
And here is the aspx markup to go with the code:
<asp:UpdatePanel ID="udpKeywordsManager" runat="server" Visible="true" UpdateMode="Conditional" >
<ContentTemplate>
<div class="keywordsManagerHeader">
<%--DISPLAY STATISTICS--%>
<asp:CheckBox ID="chkShowUsageStatistics" runat="server" Text="参照回数を表示する" AutoPostBack="true" OnCheckedChanged="chkShowUsageStatistics_CheckedChanged" CssClass="keywordsManagerCheckBoxes" TextAlign="Left" />
<%--DISPLAY ORDER--%>
<span class="keywordsManagerLabel" >並べ替え</span>
<asp:DropDownList ID="ddlKeywordsOrder" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlKeywordsOrder_SelectedIndexChanged" >
<asp:ListItem Text="なし" Value="None" />
<asp:ListItem Text="科目名" Value="Name" />
<asp:ListItem Text="参照回数" Value="Frequency" />
</asp:DropDownList>
<asp:RadioButtonList ID="rdlOrder" runat="server" AutoPostBack="true" RepeatLayout="Flow" RepeatDirection="Horizontal" CssClass="keywordsManagerRadioButtons" Enabled="false" >
<asp:ListItem Text="昇順" Value="Ascending" />
<asp:ListItem Text="降順" Value="Descending" />
</asp:RadioButtonList>
<%--UPDATE PROGRESS INDICATOR--%>
<span style="position: absolute;">
<asp:UpdateProgress ID="udpSubjectsManagerUpdateProgress" AssociatedUpdatePanelID="udpKeywordsManager" runat="server" DisplayAfter="500" DynamicLayout="False" >
<ProgressTemplate>
<img class="updateProgressIndicator" src="~/Library_Images/Animations/ajax_loading.gif" alt="" runat="server" />
</ProgressTemplate>
</asp:UpdateProgress>
</span>
</div>
<div class="keywordsManagerContainer">
<%--SUBJECTS DATALIST--%>
<asp:DataList ID="dlKeywordsManager" runat="server" DataKeyField="Keyword_ID" DataSourceID="dsBookKeywords" RepeatDirection="Horizontal"
OnItemDataBound="dlKeywordsManager_ItemDataBound" OnDeleteCommand="dlKeywordsManager_DeleteCommand" OnUpdateCommand="dlKeywordsManager_UpdateCommand" OnPreRender="dlKeywordsManager_PreRender" >
<ItemTemplate>
<span id="KeywordInfo" class="keywordsManagerItem" runat="server">
<asp:Label ID="Subject_NameLabel" runat="server" Text='<%# Eval("Keyword_Name") %>' />
<asp:Label ID="Subject_FrequencyLabel" runat="server" Text='<%# " (" + Eval("Frequency") + ")" %>' Visible="false" />
</span>
<%--HOVER MENU PANEL--%>
<asp:Panel ID="pnlKeywordContextMenu" runat="server" CssClass="keywordsManagerPopupMenuOverall">
<div class="keywordsManagerPopupMenuRow" >
<span class="keywordsManagerLabel">科目「</span>
<asp:Label ID="pnlSubjectContextMenu_Subject_NameLabel" runat="server" Text='<%# Eval("Keyword_Name") %>' />
<span class="keywordsManagerLabel">」を参照している文書数:</span>
<asp:Label ID="pnlSubjectContextMenu_Subject_FrequencyLabel" runat="server" Text='<%# Eval("Frequency") %>' />
</div>
<div ID="Book_ISO_NumbersList" class="keywordsManagerBookISONumbersList" runat="server" visible='<%# (string.IsNullOrEmpty(Eval("Book_ISO_Numbers").ToString())) ? bool.Parse("false") : bool.Parse("true") %>' >
<span class="keywordsManagerLabel">文書:</span>
<asp:Label ID="Book_ISO_Numbers_Label" runat="server" Text='<%# Eval("Book_ISO_Numbers") %>' />
</div>
<div class="keywordsManagerPopupMenuSeparator"></div>
<div class="keywordsManagerPopupMenuRow" >
<asp:TextBox ID="Keyword_NameTextBox" runat="server" Text='<%# Eval("Keyword_Name") %>' CssClass="keywordsManagerPopupMenuInput" />
<asp:Button ID="btnEdit" runat="server" Text="編集" CssClass="buttonShortBottom" CommandName="Update" CausesValidation="true" CommandArgument='<%# Eval("Keyword_Name") %>' />
<asp:Button ID="btnDelete" runat="server" Text="削除" CssClass="buttonShort" CommandName="Delete" CommandArgument='<%# Eval("Keyword_Name") %>' />
</div>
</asp:Panel>
<%--HOVER MENU EXTENDER--%>
<asp:HoverMenuExtender ID="hmeKeywordContextMenu" runat="server" TargetControlID="KeywordInfo" PopupControlID="pnlKeywordContextMenu" PopDelay="100" PopupPosition="Right" HoverDelay="100" />
</ItemTemplate>
<SeparatorTemplate>
<span class="keywordsManagerItemSeparator"></span>
</SeparatorTemplate>
</asp:DataList>
</div>
<%--MODAL POPUPS--%>
<%--CONFIRMATION POPUP--%>
<asp:Panel ID="pnlConfirmationsPopup" runat="server" CssClass="modalNotificationOverall" >
<div class="modalNotificationRow">
<asp:Label ID="lblConfirmationPopupMessage" runat="server" Text="" />
</div>
<div class="modalNotificationRow">
<asp:Button ID="btnConfirmationPopupOK" runat="server" Text="はい" CssClass="buttonMediumLong" OnClick="btnConfirmationPopupOK_Click" />
<asp:Button ID="btnConfirmationPopupCancel" runat="server" Text="いいえ" CssClass="buttonMediumLong" />
</div>
<asp:HiddenField ID="hfKeywordID" runat="server" />
<asp:HiddenField ID="hfNewKeywordName" runat="server" />
</asp:Panel>
<%--NOTIFICATION POPUP--%>
<asp:Panel ID="pnlNotificationsPopup" runat="server" CssClass="modalNotificationOverall" >
<div class="modalNotificationRow">
<asp:Label ID="lnlNotificationsPopupMessage" runat="server" Text="" />
</div>
<div class="modalNotificationRow">
<asp:Button ID="btnNotificationsPopupOK" runat="server" Text="OK" CssClass="buttonMediumLong" />
</div>
</asp:Panel>
<%--MODAL POPUP ANCHORS AND MODULES--%>
<%--DELETE CONFIRMATION--%>
<asp:Label ID="lblConfirmationPopupAnchor" runat="server" Text="" />
<asp:ModalPopupExtender ID="mpConfirmationPopup" runat="server" TargetControlID="lblConfirmationPopupAnchor" PopupControlID="pnlConfirmationsPopup" BackgroundCssClass="modalNotificationBackground" CancelControlID="btnConfirmationPopupCancel" />
<asp:Label ID="lblNotificationPopupAnchor" runat="server" Text="" />
<asp:ModalPopupExtender ID="mpNotificationPopup" runat="server" TargetControlID="lblNotificationPopupAnchor" PopupControlID="pnlNotificationsPopup" BackgroundCssClass="modalNotificationBackground" CancelControlID="btnNotificationsPopupOK" />
</ContentTemplate>
There is a lot of markup in there. The structure is as follows: I have a header section with dropdownlist, radiobuttonlist etc. which allows me to specify the sorting of the data (data comes from an object datasource)
The I have the datalist with items. Each item has a hovermenuextender in which I have the buttons to issue the edit and delete comamnds.
The modal popups are also inside the update panel, but outside the datalist, so that they can be updated as required.
My problem is that this works fine as long as the item I delete is not the last item left in the Datalist. If it is the last item the last popup (mpNotificationPopup) doesn't show.
The code executes all the way through, so the lack of items must cause the upadte panel (udpKeywordsManager) not to update?
Any help as to how to get the datalist to update in this case would be most welcome.
Thanks in advance.
Answering my own question. After painfully rebuilding the whole thing I realised that I was setting the visibility of the update panel to false in the OnPreRender event of the datalist when there were no items left. This basically switched off the update panel half-way through refreshing, so the page didn't refresh when the last element was deleted.
Have sorted it by putting a panel in the update panel which contains all the elements inside it except the "no info available" label and just toggle the visibility of that. Apologies for the stupid question, I guess I was having a stupid moment when I wrote this code...
You should show us the aspx-markup as well, but maybe you've used a ModalPopupExtender inside of your UpdatePanel. Try to move the div/Panel that has the ID of the ModalPopupExtender's PopupControlID property outside of your UpdatePanel.
You only have to nest the UpdatePanel inside of the Popup-Control and not around it.
I hope following makes it clearer:
Instead of doing it this way:
<UpdatePanel>
<DataList>
</DataList>
<ModalPopupExtender>
</ModalPopupExtender>
</UpdatePanel>
You should do it this way:
<ModalPopupExtender>
<UpdatePanel>
<DataList>
</DataList>
</UpdatePanel>
<ModalPopupExtender>

Resources