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>
Related
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.
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
This is my setup: I've got a dropdownlist of people and a linkbutton next to it to add a person. the linkbutton makes an update panel appear. When clicking save, I want the data to be saved and the new person be selected in the dropdown. As far as I can tell, I have done this properly. After I save the data I refresh the dropdownlist and take the new person's value and set it as the selected value. When stepping through, it shows the ddl with the new person and the new person selected! BUT, when the page comes back, the ddl is unchanged, ie NOT refreshed. I thought it might be something with the Update Panel but I got a similar setup to work on another page! It also works on a nested Update Panel (not shown in the following code). Can you think of why this "deception" is happening?
Here is some of my code. Sorry it's so long. Thanks for your help!!
public void AddRequestor_Click(object sender, ImageClickEventArgs e)
{
pnlNewRequestor.Style.Add("display", "none"); //regular panel
ibSubmitTask.Enabled = true;
ibSubmitTaskCancel.Enabled = true;
if (!((ImageButton)sender).ID.Contains("Cancel"))
{
SaveRequestor();
Functions.BindList(ddlRequestors, "Requestor", "spGetRequestors", true);
string newRequestor = txtRequestorLastName.Text + ", " + txtRequestorFirstName.Text;
ddlRequestors.ClearSelection();
ddlRequestors.Items.FindByText(newRequestor).Selected = true;
}
//ASPX Code
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="ddlRequestors" InitialValue=""
ErrorMessage="*Required" CssClass="ErrorText" ValidationGroup="valNewTask" Display="Dynamic" runat="server" />
<asp:LinkButton ID="LinkButton1" Text="Add New Requestor" CssClass="SmallerText" OnClientClick="NoPopup();" OnClick="NewRequestor_Click" runat="server"></asp:LinkButton>
</td>
</tr>
<!-- Add New Requestor Update Panel -->
<tr id="tr1" class="HideXXX" runat="server">
<td></td>
<td colspan="2" class="LeftPadding">
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel1" CssClass="AddNewPanel Hide" runat="server">
<table width="100%">
<tr>
<td class="SectionTitle" colspan="3"><asp:Label ID="Label1" Text="Add New Requestor" runat="server"></asp:Label>
<hr class="hrSectionTitle" />
</td>
</tr>
<tr id="tr2" class="Hide" runat="server">
<td></td>
<td class="LeftPadding"><asp:Label ID="Label2" CssClass="ErrorTextLarge" runat="server"></asp:Label></td>
</tr>
<tr>
<td><asp:Label ID="Label3" Text="First Name:" runat="server"></asp:Label> </td>
<td><asp:TextBox ID="TextBox1" CssClass="TextBox DefaultFont" OnFocus="this.className='TextBoxFocus DefaultFont'" onBlur="this.className='TextBox DefaultFont'" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="txtRequestorFirstName"
ErrorMessage="*Required" CssClass="ErrorText" ValidationGroup="valNewRequestor" Display="Dynamic" runat="server" />
</td>
</tr>
<tr>
<td><asp:Label ID="Label4" Text="Last Name:" runat="server"></asp:Label> </td>
<td><asp:TextBox ID="TextBox2" CssClass="TextBox DefaultFont" OnFocus="this.className='TextBoxFocus DefaultFont'" onBlur="this.className='TextBox DefaultFont'" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="txtRequestorLastName"
ErrorMessage="*Required" CssClass="ErrorText" ValidationGroup="valNewRequestor" Display="Dynamic" runat="server" />
</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<asp:ImageButton ID="ImageButton1" ImageUrl="~/Images/Button-AddRequestor.jpg" CausesValidation="true" ValidationGroup="valNewRequestor" OnClientClick="NoPopup();" OnClick="AddRequestor_Click" runat="server" />
<asp:ImageButton ID="ImageButton2" ImageUrl="~/Images/Button-Cancel-Darker.jpg" CausesValidation="false" OnClientClick="NoPopup();" OnClick="AddRequestor_Click" runat="server" />
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lbNewRequestor" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="ibAddRequestor" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="ibAddRequestorCancel" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
I had a similar isssue. Fixed it by mannually adding the new listitem to the dropdown instead of rebinding it ...