Child Update Panel don't to get refresh - c#

I have problem in nested update panel. I binding the gridview by using user control and my listbox is in the child update panel while selecting the items in listbox the page is getting refresh. but I don't want to get refresh.
Here is my aspx:
<%# Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SearchModule._Default" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<link type="text/css" rel="stylesheet" href="Defaultstylesheet.css" />
<script src=<%--"Scripts/jquery-1.8.2.js" type="text/javascript"> </script> --%>
<%# Register TagPrefix="inc" TagName="sPager" Src="~/UserControls/SearchPager.ascx" %>
<asp:UpdatePanel ID="upseachr" runat="server" >
<ContentTemplate>
<div style="height: 50px;"></div>
<div class="searchtextbx">
<asp:TextBox ID="searchtext" runat="server"></asp:TextBox>
<asp:Button ID="Search" OnClick="Search_Click" CssClass="searchbtn" Text="Search" height="32" runat="server"> </asp:Button>
</div>
<asp:UpdateProgress ID="updatesearchpro" AssociatedUpdatePanelID="upseachr" runat="server" >
<ProgressTemplate>
<center>
<asp:Panel ID="searchpanel" runat="server">
<img alt="Processing" src="Images/359.gif" />
<br />
<asp:Label ID="panlab" runat="server" Text="Processing..."></asp:Label>
</asp:Panel>
</center>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="updFilters" runat="server" >
<ContentTemplate>
<div class="resultpage" style="overflow-x: scroll;">
<table>
<tr>
<div class="listbox">
<asp:Label ID="headertext" runat="server" CssClass="labelresul" Font-Bold="true" Height="50" Text="Available Filter"></asp:Label>
<span style="padding-left:10px;font-weight:700;"> <asp:HiddenField runat="server" ID="hdCount" /><asp:Label ID="Total" runat="server" Height="50"></asp:Label></span><span style="padding-left:5px;font-weight:700;"><asp:Label runat="server" ID="match" Visible="false" Text="Matches"></asp:Label> <asp:Label ID="remainingcount" ForeColor="Red" Visible="false" runat="server"></asp:Label> <asp:Label ID="remaining" runat="server" ForeColor="Red" Text="Remaining" Visible="true"></asp:Label> </span>
</div>
</tr>
<tr>
<asp:ListView ID="ListView1" runat="server" OnItemDataBound="ListView1_ItemDataBound" EnableViewState="false">
<ItemTemplate>
<td>
<asp:Label ID="listheader" runat="server" Text='<%# Eval("additional_info_name1") %>'></asp:Label>
<asp:ListBox ID="results" Width="200" Visible="true" runat="server" SelectionMode="Multiple" AutoPostBack="true" OnSelectedIndexChanged="results_SelectedIndexChanged" ></asp:ListBox>
</td>
</ItemTemplate>
</asp:ListView>
</tr>
<tr>
<td class="listbox1">
<asp:Button ID="btn" runat="server" Font-Size="12" Font-Bold="true" CssClass="searchbtn" OnClick="btn_Click" Text="Apply Filter" />
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div style="height: 40px;"></div>
<div class="resultpage" style="overflow-y: scroll;">
<asp:UpdatePanel ID="updPager" runat="server">
<ContentTemplate>
<inc:sPager ID="sPager" runat="server" OnPageIndexChanging="sPager_OnPageIndexChanging"></inc:sPager>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="updGrid" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvResults" runat="server" AutoGenerateColumns="false" ItemStyle-VerticalAlign="Middle" AllowSorting="true"
ItemStyle-HorizontalAlign="Center" GridLines="None" CellSpacing="10" CellPadding="2" AllowCustomPaging="true" OnSorting="gvResults_Sorting"
AllowPaging="True" PageSize="20" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"
HeaderStyle-CssClass="GridHeader" RowStyle-HorizontalAlign="Left" CssClass="GridStyle" >
<Columns >
<asp:TemplateField HeaderText="Stock Code" SortExpression="manufacturer_part_number" >
<ItemTemplate>
<asp:Label ID="lblFirstName" Text='<%# DataBinder.Eval(Container.DataItem, "manufacturer_part_number")%>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Manufacturer" SortExpression="Manufacturer" HeaderText="Manufacturer"></asp:BoundField>
<asp:BoundField DataField="Description" SortExpression="Description" HeaderText="Description"></asp:BoundField>
<asp:BoundField DataField="Availability" SortExpression="Availability" HeaderText="Availability"></asp:BoundField>
<asp:BoundField DataField="flag_rohs" SortExpression="flag_rohs" HeaderText="RoHS"></asp:BoundField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>

It appears that your top-level UpdatePanel has an UpdateModeof Always (which is the default).
The MSDN documentation states:
If the UpdateMode property is set to Always, the UpdatePanel
control's content is updated on every postback that originates from
anywhere on the page. This includes asynchronous postbacks from
controls that are inside other UpdatePanel controls and postbacks
from controls that are not inside UpdatePanel controls.
You can rectify this by changing your top-level UpdatePanel control to conditional. e.g:
<asp:UpdatePanel ID="upseachr" runat="server" UpdateMode="Conditional">
Cheers

Related

Where should I put my UpdatePanel

I have been tasked with updating an ASP web Application to Visual Studio 2015. I have a Master page that looks like this:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="HorizontalMenu.master.cs" Inherits="HomiLog2015.HorizontalMenu" %>
<%# Register Src="~/Header and Footer/Footer.ascx" TagPrefix="uc1" TagName="Footer" %>
<%# Register Src="~/Header and Footer/Header.ascx" TagPrefix="uc1" TagName="Header" %>
<%# Register Src="~/Menu.ascx" TagPrefix="uc1" TagName="Menu" %>
<link href="App_Themes/Rockies/BaseStyles.css" rel="stylesheet" />
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body id="Body1" runat="server">
<form runat="server" id="form1" method="post">
<asp:ScriptManager ID="scriptManager1" runat="server" EnablePartialRendering="True" EnablePageMethods="True" EnableScriptGlobalization="True" EnableScriptLocalization="True">
</asp:ScriptManager>
<table border="0">
<tr>
<td class="pcT" colspan="2">
<uc1:Header runat="server" ID="Header1" />
</td>
<td class="pcTR"></td>
</tr>
<tr>
<td class="pcml"></td>
<td class="MLMmc">
<uc1:Menu runat="server" id="Menu1" />
</td>
</tr>
<tr>
<td class="pcL"></td>
<td class="pcC">
<asp:ContentPlaceHolder id="PageContent" runat="server"/>
</td>
<td class="pcR"></td>
</tr>
<tr>
<td class="pcBL"></td>
<td class="pcB">
<uc1:Footer runat="server" ID="Footer1" />
</td>
<td class="pcBR"></td>
</tr>
</table>
</form>
</body>
</html>
I Have an ASP web page with a GridView and need to Edit, Delete, and Insert records. I have gotten the edit and delete functions running but am having a problem with the Insert portion.
When I attempt to save the new record all of the data fields are empty. I know the C# code is reading the text values on the row because I have a dropdown and a checkbox on the rows that are getting their values, but it is the default values and not the ones I selected for the insert.
Pretty sure it is a post back problem since I have noticed I don't have an UpdatePanel on my web page. I have tried to wrap the gridview within an UpdatePanel but when I do that I get the error stating GridView is not a known element. I have tried wrapping the gridview in a Div and then wrapping the div in the update panel. But then I get the Error div cannot be nested in the update panel.
So I think I need to include the update panel on the Master page but cannot get it to compile when I move it over there. I have tried putting the panel in various location on the Master Page. Can someone point me in the right direction on this?
I have been asked to provide more code here is the ASPX page that has the gridview
<%# Page Title="" Language="C#" MasterPageFile="~/HorizontalMenu.Master"
AutoEventWireup="true" CodeBehind="EditMembers.aspx.cs"
Inherits="HomiLog2015.EditMembers" %>
<%# Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI"
TagPrefix="telerik" %>
<asp:Content ID="Content2" ContentPlaceHolderID="PageContent"
runat="server">
<section id="searchHeader" class="Search">
<p class="searchp">Members</p>
</section>
<section id="SearchArea" class="SearchBar">
Search for:
<br />
<br />
Last Name:
</section>
<section id="searchFooter" class="Search">
<p>*</p>
</section>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"
Skin="Default"></telerik:RadAjaxLoadingPanel>
<telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" />
<section id="grid" class="Grid-Container">
<p style="text-align: Left;">
<asp:Button ID="btnAdd" runat="Server" Text="Add New Record"
OnClick="btnAdd_Click" /></p>
<asp:GridView ID="MembersGridView" runat="server" EnableViewState="true"
DataKeyNames="UserId"
AutoGenerateColumns="false"
AutoGenerateEditButton="true"
AutoGenerateDeleteButton="false"
OnRowDataBound="MembersGridView_RowDataBound"
OnRowEditing="MembersGridView_RowEditing"
OnRowCancelingEdit="MembersGridView_RowCancelingEdit"
OnRowUpdating="MembersGridView_RowUpdating"
OnRowUpdated="MembersGridView_RowUpdated"
OnRowDeleting="MembersGridView_RowDeleting"
OnRowCommand="MembersGridView_RowCommand"
OnSorting="MembersGridView_Sorting"
AllowPaging="true"
AllowSorting="true"
EmptyDataText="No Data Has Been Entered"
HorizontalAlign="Left"
ShowFooter="false"
OnPageIndexChanging="MembersGridView_PageIndexChanging"
BackColor="White" BorderColor="#999999" BorderStyle="Solid"
BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton runat="server" ID="MembersDeleteButton"
CommandArgument='<%#Eval("username")%>'
OnClientClick="return confirm('Are you sure you want
to delete this event?');"
OnCommand="DeleteMember" Text="Delete"
ImageUrl="../Images/Icon_delete.gif">
</asp:ImageButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Valid" ItemStyle-Width="10">
<ItemTemplate>
<asp:CheckBox ID="chkActive" runat="server" Checked='<%#
Eval("valid")%>' Enabled="false"></asp:CheckBox>
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="chkActive" runat="server" Checked='<%#
Eval("valid")%>'></asp:CheckBox>
</EditItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="chkActive" runat="server" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="First Name" ItemStyle-
Width="100">
<ItemTemplate>
<asp:Label ID="lblFirstName" runat="server" Text='<%#
Eval("firstname")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtFirstName" runat="server" Text='<%#
Eval("firstname")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtFirstName" Text="Hello"
runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Last Name" ItemStyle-Width="100">
<ItemTemplate>
<asp:Label ID="lblLastName" runat="server" Text='<%#
Eval("Lastname")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtLastName" runat="server" Text='<%#
Eval("Lastname")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtLastName" runat="server">
</asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="User Name" ItemStyle-Width="100">
<ItemTemplate>
<asp:Label ID="lblUsertName" runat="server" Text='<%#
Eval("username")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtUserName" runat="server" Text='<%#
Eval("username")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtUserName" runat="server">
</asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Role" ItemStyle-Width="100">
<ItemTemplate>
<asp:Label ID="lblRole" runat="server" Text='<%#
Eval("role")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlRole" runat="server"
DataTextField="Role1" DataValueField="RoleID"></asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlRole" runat="server"
DataTextField="Role1" DataValueField="RoleID"></asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Email" ItemStyle-Width="100">
<ItemTemplate>
<asp:Label ID="lblEmail" runat="server" Text='<%#
Eval("EmailAddress")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtemail" runat="server" Text='<%#
Eval("EmailAddress")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<asp:Button ID="btnInsert" runat="Server" Text="Insert"
CommandName="Insert" UseSubmitBehavior="False" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Mode="Numeric"
Position="Bottom"
PageButtonCount="10" />
<AlternatingRowStyle BackColor="#CCCCCC" />
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999"
Height="30px"
VerticalAlign="Bottom"
HorizontalAlign="center" ForeColor="Black" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True"
ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
<EmptyDataTemplate>
<asp:CheckBox ID="chkActive" runat="server" Checked='<%#
Eval("valid")%>' Enabled="false"></asp:CheckBox>
<asp:Label ID="lblFirstName" runat="server" Text='<%#
Eval("firstname")%>'></asp:Label>
<asp:Label ID="lblLastName" runat="server" Text='<%#
Eval("Lastname")%>'></asp:Label>
<asp:Label ID="lblUsertName" runat="server" Text='<%#
Eval("username")%>'></asp:Label>
<asp:DropDownList ID="ddlRole" runat="server"
DataTextField="Role1" DataValueField="RoleID"></asp:DropDownList>
<asp:Label ID="lblEmail" runat="server" Text='<%#
Eval("EmailAddress")%>'></asp:Label>
</EmptyDataTemplate>
</asp:GridView>
</section>
</asp:Content>
I have tried putting the update panel in various locations on this page but it will not compile.
Master pages are for styling. You should not be touching them in this case.
Add the MasterPageFile attribute to the Page element in your .aspx markup file that contains your GridView.
<%# Page MasterPageFile="~/YOUR_MASTER_PAGE_FILE" ... %>
Note the id of the asp:ContentPlaceHolder in your Master page.
<asp:ContentPlaceHolder id="PageContent" runat="server"/>
Wrap the content of your new .aspx page in a asp:Content element which has an attribute asp:ContentPlaceHolderID equal to the ID of the asp:ContentPlaceHolder element in your master page file.
<asp:Content ID="mainPlaceHolder" ContentPlaceHolderID="PageContent" runat="server">
Here is an example for inserting records using a GridView
Please post the relevant markup and back-end code for you GridView and insert logic. I can't offer any more assistance based on the information provided.

Ajax TabContainer third tabpanel is not displaying in browser

i am using asp.net ajax tab container. i have added six tab panel but third tab panel is not displaying in browser. i have used this inside a user control. Even i moved panel back and forth but panel always on third position is not display. i search this on google but did found any solution.
<asp:TabContainer ID="EmpTabContainer" runat="server" ActiveTabIndex="0" Width="100%">
<asp:TabPanel ID="ActivePanel" runat="server" Font-Bold="true">
<HeaderTemplate>
<asp:Label ID="Label2" runat="server" meta:resourcekey="Active" Font-Bold="true"></asp:Label>
</HeaderTemplate>
<ContentTemplate>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="OnLeavePanel" runat="server" Font-Bold="true">
<HeaderTemplate>
<asp:Label ID="Label3" runat="server" meta:resourcekey="OnLeave" Font-Bold="true"></asp:Label>
</HeaderTemplate>
<ContentTemplate>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TerminatedPanel" runat="server" Font-Bold="true">
<HeaderTemplate>
<asp:Label ID="Label53" runat="server" meta:resourcekey="Terminated" Font-Bold="true"></asp:Label>
</HeaderTemplate>
<ContentTemplate>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="ResignedPanel" runat="server" Font-Bold="true" >
<HeaderTemplate>
<asp:Label ID="Label4" runat="server" meta:resourcekey="Resigned" Font-Bold="true"></asp:Label>
</HeaderTemplate>
<ContentTemplate>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="BlockedPanel" runat="server" Font-Bold="true" >
<HeaderTemplate>
<asp:Label ID="Label6" runat="server" meta:resourcekey="Blocked" Font-Bold="true"></asp:Label>
</HeaderTemplate>
<ContentTemplate>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="DidNotJoinPanel" runat="server" Font-Bold="true" >
<HeaderTemplate>
<asp:Label ID="Label7" runat="server" meta:resourcekey="NotJoined" Font-Bold="true"></asp:Label>
</HeaderTemplate>
<ContentTemplate>
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>

set page height

I've got a search page that has the criteria in a panel, when the page opens obviously there are no results and the page footer is appearing directly beneath the search panel. How do I set the results panel to be a set height, then stretch to be the height of the grid when search results are found.
Cheers
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="FrmSearch.aspx.cs" Inherits="web.FrmSearch" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:UpdatePanel ID="pnlUpdate" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<div id="divSearch">
<asp:Panel ID="pnlSearch" runat="server" DefaultButton="BtnSearch">
<table width="100%">
<tr>
<td>
<asp:Label ID="LblName" runat="server" Text="Name:" CssClass="head2"></asp:Label>
</td>
<td>
<asp:TextBox ID="TxtSurname" runat="server" Width="200" CssClass="norm"></asp:TextBox>
</td>
<tr>
<td>
<asp:Label ID="LblAddress" runat="server" Text="Address:" CssClass="head2"></asp:Label>
</td>
<td>
<asp:TextBox ID="TxtAddress" runat="server" Width="200" CssClass="norm"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="BtnSearch" runat="server" Text="Search" OnClick="BtnSearch_Click" />
</td>
<td colspan="2" align="center">
<asp:Button ID="BtnReset" runat="server" Text="Reset" OnClick="BtnReset_Click" />
</td>
</tr>
</table>
</asp:Panel>
</div>
<div>
<asp:Label ID="lblCount" runat="server" CssClass="head2"></asp:Label>
</div>
<hr />
<div id="divResults">
<asp:Panel ID="pnlResults" runat="server">
<asp:GridView ID="gvResults" runat="server" AutoGenerateColumns="false" Width="99%"
CssClass="grd" OnRowDataBound="gvResults_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:HiddenField ID="hfGUID" runat="server" Value='<%# Bind("GUID")%>' />
<asp:Label ID="LblName" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemTemplate>
<asp:Label ID="LblAddress" runat="server" Text='<%# Bind("Address") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Post Code">
<ItemTemplate>
<asp:Label ID="LblPostCode" runat="server" Text='<%# Bind("Post_Code") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Telephone">
<ItemStyle Width="150px" />
<ItemTemplate>
<asp:Label ID="LblTelephone" runat="server" Width="150px" Text='<%# Bind("Telephone") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Panel>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSearch" />
<asp:AsyncPostBackTrigger ControlID="btnReset" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
You can use min-height:200px to divSearch container.
#divSearch
{
min-height:200px //according to your requirement
}

First modalpopup in first panel does not open until second modalpopup opens in second panel

I have one updatepanel exists with two panels. Each panel have two buttons to open popup. I have two modalpopup & its target panels just below of two panels.Everything is working fine, but I am getting problem, if I click button in first panel then modalpopup does not open, but when I click button in second panel after click button in first panel then popup opens & viceversa.
I used following code:
<asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnl1" runat="server">
<asp:Button ID="btn1" runat="server" class="add-btn-1" Text="Add" />
</asp:Panel>
<asp:Panel ID="pnl2" runat="server">
<asp:Button ID="btn2" runat="server" class="add-btn-1" Text="Add" />
</asp:Panel>
<cc1:ModalPopupExtender ID="ModalPopup1" PopupControlID="pnlpopup1" TargetControlID="btn1"
BackgroundCssClass="modalBackground" runat="server" />
<asp:Panel runat="server" ID="pnlpopup1">
<%--code here--%>
</asp:Panel>
<cc1:ModalPopupExtender ID="ModalPopup2" PopupControlID="pnlpopup2" TargetControlID="btn2"
BackgroundCssClass="modalBackground" runat="server" />
<asp:Panel runat="server" ID="pnlpopup2">
<%--code here--%>
</asp:Panel>
</ContentTemplate>
What will be solution to solve this problem?
Thank you.
I executed your code and found no problems.It works.So post the code that you have given inside <%--code here--%>.I would also suggest that you add a OkControlID to your ModalPopupExtender.
<asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnl1" runat="server">
<asp:Button ID="btn1" runat="server" class="add-btn-1" Text="Add" />
</asp:Panel>
<asp:Panel ID="pnl2" runat="server">
<asp:Button ID="btn2" runat="server" class="add-btn-1" Text="Add" />
</asp:Panel>
<Ajax:ModalPopupExtender ID="ModalPopup1" PopupControlID="pnlpopup1" TargetControlID="btn1"
BackgroundCssClass="modalBackground" runat="server" />
<asp:Panel runat="server" ID="pnlpopup1" Style="width:400px;height:100px; background: gray;">
<table width="100%">
<tr>
<td align="left">
<asp:Label ID="lblheadinglunchout" Font-Underline="true" Text="First Popup"
runat="server" CssClass="labelPopup" Style="text-decoration: none"></asp:Label>
</td>
<td align="right">
<asp:ImageButton ID="imgbtnCancelPopUp" ImageUrl="Images/popupclose_button.png"
runat="server" Style="vertical-align: top;" CssClass="button" />
</td>
</tr>
</table>
</asp:Panel>
<Ajax:ModalPopupExtender ID="ModalPopup2" PopupControlID="pnlpopup2" TargetControlID="btn2"
BackgroundCssClass="modalBackground" runat="server" />
<asp:Panel runat="server" ID="pnlpopup2" Style="width:400px;height:100px; background: gray;">
<table width="100%">
<tr>
<td align="left">
<asp:Label ID="Label1" Font-Underline="true" Text="Secound Popup"
runat="server" CssClass="labelPopup" Style="text-decoration: none"></asp:Label>
</td>
<td align="right">
<asp:ImageButton ID="ImageButton1" ImageUrl="Images/popupclose_button.png"
runat="server" Style="vertical-align: top;" CssClass="button" />
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>

Combobox selected item is deleted once selected . Invalid Postback or Callback argument

I have four textboxes one combobox and one button ( and some other controls) in my page . Based on the values typed in the textboxes the related values are updated in the combobox. On clicking the submit button in my page It was giving the following error .
"Invalid postback or callback argument. Event validation is enabled using in configuration or in a page. For Secuity 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.RegisterForEventsValidation method in order to register the postback or callback data for validation."
Now in the page directive I added
<%#Page EnableEentValidation="false">
When I type the values in the four textboxes the corresponding value will appear in the cobobox . But when I select that combobox value, the selected value wil be deleted . What is the reason for this ?
<%# Page Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="AddeChecklist.aspx.cs"
Inherits="LabTrack.WebApplication.Echecklist.AddeChecklist" EnableEventValidation ="false" %>
<%# Register TagPrefix="Labinal" TagName="AutoCompleteControl" Src="~/UserControls/AutoCompleteEnabledWebUserControl.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="../Styles/CheckListRev.css" rel="stylesheet" type="text/css" />
<!-- Style for the page -->
<link href="../Styles/AddeChecklist.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server">
</asp:ScriptManager>
<asp:Panel ID="ErrorMessagePanel" CssClass="ErrorPanel" Visible="true" runat="server">
<div class="ErrorDiv">
<asp:BulletedList CssClass="ErrorMessage" ID="ErrorMessageBulletedList" runat="server">
</asp:BulletedList>
</div>
</asp:Panel>
<div class="PageTitle">
<asp:Label ID="PageHeaderLabel" runat="server"></asp:Label>
</div>
<div class="MainDiv">
<div style="text-align: center;">
<div class="PlaceHolder">
<table id="formTable">
<tr>
<td>
<asp:UpdatePanel runat="server" ID="updatepanelCustomer" UpdateMode="Conditional">
<ContentTemplate>
<span class="boldLabelLong">Customer:</span><br />
<asp:TextBox ID="CustomerNameTextBox" Width="200" runat="server"></asp:TextBox>
<asp:HiddenField ID="IxCustomerHiddenField" runat="server" />
<asp:Button ID="customerTriggerbutton" runat="server" Text="Button" Style="display: none;" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td>
<asp:UpdatePanel runat="server" ID="updatepanelProgram" UpdateMode="Conditional">
<ContentTemplate>
<span class="boldLabelLong">Program:</span><br />
<asp:TextBox ID="ProgramNameTextBox" Width="200" runat="server"></asp:TextBox>
<asp:Button ID="programTriggerbutton" runat="server" Text="Button" Style="display: none;" />
<asp:HiddenField ID="IxProgramHiddenField" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="customerTriggerbutton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</td>
<td>
<asp:UpdatePanel runat="server" ID="updatepanelWorkPackage" UpdateMode="Conditional">
<ContentTemplate>
<span class="boldLabelLong">WorkPackage:</span><br />
<asp:TextBox ID="WorkPackageNameTextBox" Width="200" runat="server"></asp:TextBox>
<asp:HiddenField ID="IxWorkPackageHiddenField" runat="server" />
<asp:Button ID="workPackageTriggerbutton" runat="server" Text="Button" Style="display: none;" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="programTriggerbutton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</td>
<td>
<asp:UpdatePanel runat="server" ID="updatepanelActivity" UpdateMode="Conditional">
<ContentTemplate>
<span class="boldLabelLong">Activity:</span><br />
<asp:TextBox ID="ActivityNameTextBox" Width="200" runat="server"></asp:TextBox>
<asp:HiddenField ID="IxActivityHiddenField" runat="server" />
<asp:Button ID="activityTriggerbutton" runat="server" Text="Button" Style="display: none;" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="workPackageTriggerbutton" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="activityTriggerbutton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
</table>
</div>
<div class="PlaceHolder">
<asp:Label ID="TemplateLabel" Text="Template:" CssClass="ControlLabel" runat="server"></asp:Label>
<asp:UpdatePanel runat="server" ID="updatepanelTemplate" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="TemplateSelectDropDownList" runat="server" Width="400" Visible="true"
AutoPostBack="true">
</asp:DropDownList>
<asp:HiddenField ID="IxTemplateHiddenField" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="workPackageTriggerbutton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Panel ID="SustainPanelTemplateOwner" Visible="true" runat="server">
<div>
<asp:Label ID="TemplateOwnerLabel" Text="Owner:" CssClass="ControlLabel" runat="server"></asp:Label>
<asp:TextBox ID="TemplateOwnerTextBox" CssClass="controlMargin" Width="400" runat="server"></asp:TextBox>
</div>
</asp:Panel>
<asp:HiddenField ID="IxDeliverableHiddenField" runat="server" />
<asp:HiddenField ID="IxReleaseActionHiddenField" runat="server" />
<asp:HiddenField ID="IxConfigHiddenField" runat="server" />
<asp:HiddenField ID="IxTemplateOwnerHiddenField" runat="server" />
<asp:HiddenField ID="TemplateSelectedSnameHiddenField" runat="server" />
<asp:HiddenField ID="TemplateOwnerSelectedsNameHiddenField" runat="server" />
<asp:HiddenField ID="DeliverableSelectedHiddenField" runat="server" />
<div>
<asp:Label ID="DeliverableLabel" CssClass="ControlLabel" runat="server" Text="Deliverable:"></asp:Label>
<asp:TextBox ID="DeliverableTextBox" CssClass="controlMargin" Width="400" runat="server"></asp:TextBox>
</div>
<asp:Panel ID="SustainPanelConfig" Visible="true" runat="server">
<div>
<asp:Label ID="ConfigurationLabel" runat="server" Text="Configuration:" CssClass="ControlLabel"></asp:Label>
<select id="ConfigurationSelect" class="controlMargin">
<option></option>
</select>
</div>
</asp:Panel>
<asp:Panel ID="SustainPanelRelease" Visible="true" runat="server">
<div>
<asp:Label ID="ReleaseActionLabel" CssClass="ControlLabel" runat="server" Text="Release Action:"></asp:Label>
<asp:TextBox ID="ReleaseActionTextBox" CssClass="controlMargin" Width="400" runat="server"></asp:TextBox>
</div>
</asp:Panel>
<asp:Panel ID="SustainPanel" Visible="true" runat="server">
<div class="SustainPanelControls">
<div>
<asp:Label ID="ChangeLabel" Text="Change #: " runat="server"></asp:Label>
</div>
<div>
<asp:TextBox ID="ChangeTextBox" Width="110" runat="server"></asp:TextBox>
</div>
<div>
<asp:Label ID="SupplementLabel" Text="Supplement: " runat="server"></asp:Label>
</div>
<div>
<asp:TextBox ID="SupplementTextBox" Width="80" runat="server"></asp:TextBox>
</div>
<div>
<asp:Label ID="NewWrrLabel" Text="WRR #: " runat="server"></asp:Label>
</div>
<div>
<asp:TextBox ID="NewWrrTextBox" Width="80" runat="server"></asp:TextBox>
</div>
<div>
<asp:Label ID="DddLabel" Text="3D: " runat="server"></asp:Label>
</div>
<div>
<asp:TextBox ID="DddTextBox" Width="80" runat="server"></asp:TextBox>
</div>
</div>
<div>
<table id="DesignDataTable2">
<tr>
<td>
<asp:Label ID="AllFbSheetsWrrLabel" Text="All F/B Sheets w/WRR #:" CssClass="ControlLabel" runat="server"></asp:Label>
</td>
<td>
<asp:TextBox CssClass="completeControl" ID="AllFbSheetsWrrTextBox" Width="588" Rows="2"
TextMode="MultiLine" runat="server"></asp:TextBox>
</td>
</tr>
</table>
</div>
</asp:Panel>
</div>
<div class="EditButtonGroup">
<input id="EditButton" type="button" value="Edit" class="ButtonSettings" />
<input id="RemoveButton" type="button" value="-" class="ButtonSettings" />
<input id="AddButton" type="button" value="+" class="ButtonSettings" />
</div>
</div>
<div class="ViewData">
<div class="ViewDataDiv">
<table id="DesignDataTable" class="designDataTable">
<tbody>
</tbody>
</table>
</div>
</div>
<div class="submitButtonDiv">
<asp:Button ID="SubmitButton" runat="server" Text="Button Text" class="submitButtonCreateChecklist" />
</div>
</div>
</asp:Content>
You are creating new values on the client side, and posting them back to the server.
For security reasons ASP.NET implements "event validation". When even validation is enabled, if the server creates a combo with 3 possible values, it will only accept this values on postback. If you create a different value and send it back to the server, you get the error you're referring to.
Here you have some info:
Page.EnableEventValidation Property
You can use ClientScriptManager.RegisterForEventValidation Method if you know which are the possible values generated on the client side, or disable validation completely if you don't know them in advance.
To disable validation:
You set the EnableEventValidation property by setting the enableEventValidation attribute of the # Page directive or the enableEventValidation attribute of the pages element in the Web.config file. If you set this property in code, you must set it before the page is initialized.
Sounds like an issue with Viewstate overriding the values.
Try fetching the value directly using Request.Form[Dropdown.ClientId]

Categories

Resources