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>
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 have two form and each form has button , i have abstracted them by two panel so when enter key in each panel pressed , proper button will send .
in one panel i have login form
<asp:Panel ID="pnlRegistered" runat="server" DefaultButton="btnLoginButton">
<LayoutTemplate>
<asp:Button ID="btnLoginButton" runat="server" CommandName="Login" Text="Login" ValidationGroup="Login1" OnClick="btnLoginButton_Click" ClientIDMode="Static" />
</LayoutTemplate>
<asp:Panel>
but i get exception
System.InvalidOperationException
The DefaultButton of 'pnlRegistered' must be the ID of a control of type IButtonControl.
You are missing the value of DefaultButton:
<asp:Panel ID="pnlRegistered" runat="server" DefaultButton="btnLoginButton">
<asp:Button ID="btnLoginButton" runat="server" CommandName="Login" Text="Login" ValidationGroup="Login1" OnClick="btnLoginButton_Click" ClientIDMode="Static" />
<asp:Panel>
EDIT: You can also set the DefaultButton in the code-behind, like so:
pnlRegistered.DefaultButton = btnLoginButton.UniqueID;
put your panel inside layouttemplate of your login control
<asp:Login ID="Login1" runat="server">
<LayoutTemplate>
<asp:Panel ID="pnlRegistered" runat="server" DefaultButton="btnLoginButton">
<asp:Button ID="btnLoginButton" runat="server" CommandName="Login" Text="Login" ValidationGroup="Login1"
ClientIDMode="Static" />
</asp:Panel>
</LayoutTemplate>
</asp:Login>
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.
The problem is described in the title. It does postbacking also when I specifically set AutoPostBack property of the ListBox to false, though it should be like that by default.
ListBox selection mode is set to multiple.
There is a similar question but with a different background.
What am I missing? Is this some well known issue?
Thank you for replying,
please tell if you need the exact code
EDIT:
Here's the aspx page. Codebehind is much larger, since this page is the target of redirection, please tell if you need additional info from there.
<%# Page Language="C#" AutoEventWireup="true" CodeFile="ReportsPreviewViewAddParams.aspx.cs" Inherits="Admin_ReportsPreviewViewAddParams" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
<form runat="server">
<asp:HiddenField ID="SqlSelect" runat="server" />
<asp:HiddenField ID="SqlColumnSize" runat="server" />
<asp:HiddenField ID="SqlGroup" runat="server" />
<asp:HiddenField ID="SqlOrder" runat="server" />
<asp:HiddenField ID="PageSize" runat="server" />
<asp:HiddenField ID="SumColumns" runat="server" />
<asp:Repeater ID="RepeaterInput" runat="server" OnItemDataBound="OnRepeaterItemDataBound" >
<HeaderTemplate>
<table>
<tr><th>
<asp:Label ID="LabelHeader" runat="server" Text='<%# Webcom.Configurator.Core.MLPersistentManager.GetKeyValue("Admin.Reports.EnterParams") %>' />
</th></tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:TextBox ID="TextBoxValueOne" runat="server" AutoPostBack="false" />
<asp:ListBox ID="ListBoxControlOne" runat="server" AutoPostBack="false" />
</td>
<td><asp:Label ID="LabelOperatorOne" runat="server" /></td>
<td><asp:Label ID="LabelColumnName" runat="server" /></td>
<td><asp:Label ID="LabelOperatorTwo" runat="server" /></td>
<td>
<asp:TextBox ID="TextBoxValueTwo" runat="server" AutoPostBack="false" />
<asp:ListBox ID="ListBoxControlTwo" runat="server" AutoPostBack="false" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<asp:Button ID="buttonSubmit" runat="server" Visible="true" OnClick="OnSubmit" />
</form>
</body>
</html>
The repeater does not have a way of tracking autopostbacks that happen from controls within the repeater. This may offer you a clue:
Handling autopostbacks within a repeater
You could try initializing the AutoPostBack property early in the code-behind page life-cycle, perhaps in Page Load method (after page controls have been created):
ListBox ListBoxControlOne = (ListBox)RepeaterInput.FindControl("ListBoxControlOne");
ListBoxControlOne.AutoPostBack = false;
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