The rich text box (SharePoint control) gets duplicated on partial postbackl. How to overcome this issue? This control is outside the update panel.
<asp:UpdatePanel ID="ExternalCCUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table>
<tr>
<td width="45px"></td>
<td>
<asp:ListBox Width="182px" Height="200px" Visible="true" ID="ccEmailListBox" SelectionMode="Multiple" runat="server" ToolTip="Select external user/group names"></asp:ListBox>
</td>
<td width="22px"></td>
<td width="60px">
<asp:Button Width="50px" ID="addToCCSelectedBoxButton" CausesValidation="false" CssClass="submitButton" Text="Add >" runat="server" OnClick="addToCCSelectedBoxButton_Click" /><br />
<asp:Button Width="50px" ID="removeFromCCSelectedListBox" CausesValidation="false" CssClass="submitButton" Text="< Remove" runat="server" OnClick="removeFromCCSelectedListBox_Click" />
</td>
<td width="22px"></td>
<td>
<asp:ListBox Width="182px" Height="200px" Visible="true" SelectionMode="Multiple" ID="ccEmailSelectedListBox" runat="server"></asp:ListBox>
</td>
<td>
<asp:UpdateProgress ID="ExternalCCUpdateProgress" runat="server" AssociatedUpdatePanelID="ExternalCCUpdatePanel" DynamicLayout="true">
<ProgressTemplate>
<img src="/progress.gif"></img><br />
Please Wait...
</ProgressTemplate>
</asp:UpdateProgress>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="addToCCSelectedBoxButton" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="removeFromCCSelectedListBox" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<SharePoint:InputFormTextBox ID="RichTextBox"
RichText="true" Rows="20"
RichTextMode="FullHtml" runat="server"
TextMode="MultiLine">
</SharePoint:InputFormTextBox>
The problem occurs when the buttons are clicked inside the update panel. The functionality of the buttons are to add/remove entries from the list boxes.
Please try 2 different things. One - remove all the content from the update panel except the buttons and see if the problem persists. If it does I would consider looking at any master pages you have wrapped around this page and try and verify all your controls and html tags are property closed.
Second, try wrapping the richtextbox in a separate update panel and marking the mode conditional.
From the information you have I can't see what is causing the problem, but this may help fix the error or give you other places to look for the root cause.
Related
I am trying to use UpdatePanels, PopupControlExtenders, and a custom control to create a dropdown list of checkboxes. It works for the most part except for 1 odd glitch I cant seem to find a way around.
EnhancedCheckboxList.cs
Default.aspx
Default.aspx.cs
In order to replicate the glitch you have to perform the following actions in the order below.
Set A Dropdown to Role2
Set B Dropdown to Role2
Invert all A Authorities (Uncheck checked items and check unchecked items)
Set B Dropdown to Role1
View A Authorities (The items we unchecked in step 3 have become checked again)
For whatever reason unchecking the Authorities in step 3 has no effect but checking them does? I looked into getting the correct values from Request.Params but it doesnt look like that is giving me what I want. The glitch will only happen if you perform the steps in that order if you switch steps 2 and 3 it works fine.
Would you consider eliminating the UpdatePanels? I was able to reproduce the glitch using your original code. Once I removed the UpdatePanels the glitch is no longer reproducible:
<fieldset>
<legend>Role</legend>
<table width="500">
<tr>
<td>A</td>
<td valign="top">
<asp:DropDownList ID="Roles" runat="server" AutoPostBack="True" OnSelectedIndexChanged="roles_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td valign="top">
<%-- <asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>--%>
<asp:TextBox ID="txtAuthority" Text="Authorities" runat="server" CssClass="txtboxaschkbox" Visible="false"></asp:TextBox>
<asp:Panel runat="server" ID="PnlAuth" Visible="false" CssClass="PnlDesign">
<cc1:EnhancedCheckboxList ID="Authorities" runat="server">
</cc1:EnhancedCheckboxList>
</asp:Panel>
<cc2:PopupControlExtender runat="server" ID="PceSelectAuthority" TargetControlID="txtAuthority"
PopupControlID="PnlAuth" Position="Bottom"/>
<%-- </ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Roles" />
</Triggers>
</asp:UpdatePanel>--%>
</td>
</tr>
<tr>
<td>B</td>
<td valign="top">
<asp:DropDownList ID="Roles2" runat="server" AutoPostBack="True" OnSelectedIndexChanged="roles2_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td valign="top">
<%-- <asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>--%>
<asp:TextBox ID="txtAuthority2" Text="Authorities" runat="server" CssClass="txtboxaschkbox" Visible="false"></asp:TextBox>
<asp:Panel runat="server" ID="PnlAuth2" Visible="false" CssClass="PnlDesign">
<cc1:EnhancedCheckboxList ID="Authorities2" runat="server">
</cc1:EnhancedCheckboxList>
</asp:Panel>
<cc2:PopupControlExtender runat="server" ID="PceSelectAuthority2" TargetControlID="txtAuthority2"
PopupControlID="PnlAuth2" Position="Bottom"/>
<%-- </ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Roles2" />
</Triggers>
</asp:UpdatePanel>--%>
</td>
</tr>
</table>
</fieldset>
I have an asp:TextBox in an ajax popup panel. I've searched for a way to make a new line when the user presses the "Enter/Return" key, but nothing has worked so far.
Here is my TextBox:
<asp:TextBox ID="CommentaireSaveTxt" MaxLength="4999" TextMode="MultiLine"
Width="250px" Height="100px" runat="server" />
I've read that sometimes the enter key defaults to a button without any indication that it will do so, but none of my ajax panel's buttons events are firing. As far as I know, nothing happens at all. I suspect there might be some kind of problem with my textbox being in the panel.
Here is my AJAX:
<ajaxToolkit:ModalPopupExtender ID="btnSauvegarder_ModalPopupExtender"
runat="server" TargetControlID="DummySauvegarder"
PopupControlID="btnSauvegarder_ModalPopupExtender_PNL"
CancelControlID="ButtonCancel"
BackgroundCssClass="modalBackground"
Enabled="True" DynamicServicePath="" />
<asp:Panel ID="btnSauvegarder_ModalPopupExtender_PNL"
Style="display: none;"
CssClass="modalPNL"
runat="server"
meta:resourcekey="btnSauvegarder_ModalPopupExtender_PNLResource1">
<table border="0">
<tr>
<td>
<img src="..\Images\IconQuestion.png" alt="Question" />
<asp:TextBox ID="CommentaireSaveTxt" MaxLength="4999" Rows="50"
TextMode="MultiLine" Width="250px"
Height="100px" runat="server" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblMessageSauvegarder" runat="server"
meta:resourcekey="lblMessageSauvegarderResource1">
</asp:Label>
</td>
</tr>
</table>
<div style="text-align: right;">
<asp:Button ID="ButtonOkSauvegarder" runat="server" Text="OK"
OnClick="ButtonOkSauvegarder_Click"
meta:resourcekey="ButtonOkDeleteResource1" />
<asp:Button ID="ButtonCancelSauvegarder" runat="server" Text="Cancel"
meta:resourcekey="ButtonCancelResource2" />
</div>
</asp:Panel>
EDIT :
After testing...
For some reason, it doesn't work anywhere in my page. When looking at the generated html code from the browser, the textarea does not have any property for "AcceptsReturn" to true. I don't know if that can help anyone in finding the trouble.
My whole page is contained into UpdatePanel and ContentTemplate if that has any matters. I really am out of clue with what my problem is. I tested with a partner and he has no problem making it work in his projet (another website).
I'm just wondering if there's a way to add a new checkbox item to an existing asp:checkboxlist control, when another checkbox is checked, without having to do a full postback of the page. Whether it's with javascript, jquery, ajax. Just wondering how (if at all) I can do something like this.
I've been doing some research and it appears I can do a partial postback using an asp:UpdatePanel. I've never used one of these before. Does anyone have an example of how they can be used? Here's what I have, but it's still doing a full postback
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<tr>
<td width="50%">
<asp:CheckBox runat="server" ID="chkEnglish" Font-Bold="true" TextAlign="Right" Text=" English" />
</td>
<asp:Panel runat="server" ID="pnlTopLanguages">
<td rowspan="3" valign="top">
<asp:CheckBoxList ID="chkTopLanguages" CssClass="cb chkTopLangs" TextAlign="Right" runat="server" />
<asp:TextBox runat="server" ID="txtOtherLanguages" onkeyup="SetButtonStatus(this)" onclick="return clearLanguageSearchText()" Text="Other Languages..."></asp:TextBox>
<asp:Button runat="server" ID="btnAddLang" Text="Add" OnClientClick="return CopyOtherLangs()" Enabled="false" /><br /><br />
<asp:CheckBox runat="server" ID="chkManyOtherLanguages" CssClass="cb" Font-Bold="true" Text="Many other languages" />
<cc3:AutoCompleteExtender ID="aceSearch" runat="server" MinimumPrefixLength="1" TargetControlID="txtOtherLanguages"
ServicePath="~/controls/wsCommunity.asmx" ServiceMethod="GetLanguageCompletionList"></cc3:AutoCompleteExtender>
</td>
</asp:Panel>
</tr>
</ContentTemplate>
</asp:UpdatePanel>
Building off Adils answer...to add a checkbox on check of another one, you can use:
$(".classOfCheckboxList").change(function() {
$(this).append("<input type='checkbox' id='newbox' class='currentclass' value='someval' />");
});
As Adil said, this new dynamically added box wont be accessible in the code-behind.
I'm facing a buggy behavior from ASP.NET Ajax Controls Toolkit ModalPopupExtender, when I call Alert() JavaScript function from server-side the modal appears in the back ground. I don't know why this is happens.
here is the code:
vb:
Sub ShowAlert(ByVal message As String)
ScriptManager.RegisterStartupScript(Me.UpdatePanel, UpdatePanel.GetType(), "notificationScript", "<script language='JavaScript'> alert('" & message & "'); </script>", False)
End Sub
aspx:
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlPartialInstructions" CssClass="modal" runat="server">
......
<asp:Panel ID="pnlPrintConfirmation" CssClass="modal" runat="server">
<table class="ui-accordion">
<tr>
<td colspan="2">
<asp:Label Text="Do you want to print the receipt?" ID="lblPrintConfirmation" runat="server"
meta:resourcekey="lblPrintConfirmationResource1" Font-Bold="True" Font-Names="tahoma"
Font-Size="Large" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnConfirmPrint" Text="Yes" CssClass="google-button google-button-blue"
runat="server" meta:resourcekey="btnConfirmSaveResource1" Font-Size="Large" />
</td>
<td>
<asp:Button ID="btnCancelPrint" Text="No" CssClass="google-button google-button-red"
runat="server" meta:resourcekey="btnCancelSaveResource1" Font-Size="Large" />
</td>
</tr>
</table>
</asp:Panel>
<asp:Button ID="HiddenForModel1" Text="" runat="server" CssClass="hide" CausesValidation="False" />
<ajaxToolkit:ModalPopupExtender ID="pnlPrintConfirmation_ModalPopupExtender" runat="server" DynamicServicePath=""
Enabled="True" TargetControlID="HiddenForModel1" PopupControlID="pnlPrintConfirmation"
BackgroundCssClass="ModalBackground" DropShadow="True" CancelControlID="btnCancelPrint"
RepositionMode="RepositionOnWindowResizeAndScroll">
</ajaxToolkit:ModalPopupExtender>
.....
</asp:UpdatePanel>
</ContentTemplate>
The issue is caused by the way the ModalPopupExtender works. It is emitting a JavaScript which will hide the Panel.
Now you are registering your alert() call as startup script, this will hold running the ModalPopupExtender script as long as the user will not exit the alert windown. The simplest fix is setting display:none on the Panel so it will not need the script to hide it:
<asp:Panel ID="pnlPrintConfirmation" CssClass="modal" Style="display:none;" runat="server">
...
</asp:Panel>
I used a drop down list inside a update panel.i set the required condition's but it still causing a full post back. i searched and tried everything thing which i got but it still stick to the error.
When i do the selected index change it cause full page post and show a error(by fire Bug)
Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%# Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.' when calling method: [nsIDOMEventListener::handleEvent]
here is my Code
<asp:ToolkitScriptManager ID="ToolkitScriptManager1"
runat="server" EnablePageMethods="true" EnablePartialRendering="true">
</asp:ToolkitScriptManager>
Update Panel Code
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true" >
<ContentTemplate>
<table cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr>
<td>
<asp:DropDownList ID="DDLCity" runat="server" CausesValidation="false" AutoPostBack="True" OnSelectedIndexChanged="DDLCity_SelectedIndexChanged"
Width="200px">
</asp:DropDownList>
</td>
<td>
<asp:Label ID="Label19" runat="server" Text="Pin Code"></asp:Label>
</td>
<td>
<asp:TextBox ID="TxtPinCode" runat="server" Height="20px" ReadOnly="True" ToolTip="Pin Code"
Width="100px"></asp:TextBox>
<asp:TextBoxWatermarkExtender ID="TxtPinCode_TextBoxWatermarkExtender" runat="server"
Enabled="True" TargetControlID="TxtPinCode" WatermarkCssClass="WaterMark" WatermarkText="XXXXXX">
</asp:TextBoxWatermarkExtender>
<asp:RequiredFieldValidator ID="RFVINCODE" runat="server" ControlToValidate="txtarea"
ErrorMessage="Pin Code Required" Text="*">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label17" runat="server" Text="State"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlstate" runat="server" Height="24px" OnSelectedIndexChanged="ddlstate_SelectedIndexChanged"
ToolTip="State" Width="200px">
<asp:ListItem>State</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DDLCity" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
Please help me out with this one
i Tried this scenario also but this doesn't work also.
protected override void Render(HtmlTextWriter writer)
{
ClientScript.RegisterForEventValidation(DDLCity.UniqueID.ToString());
ClientScript.RegisterForEventValidation(txtarea.UniqueID.ToString());
ClientScript.RegisterForEventValidation(ddlstate.UniqueID.ToString());
base.Render(writer);
}
Add the Location Tag settings for this page which will give the permission to execute the event asynchronously.
For more information Please check here and here