set page height - c#

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
}

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.

Render UserControl in Same line as other controls in a <td>

I want to render Usercontrol in the same line as my other controls in . By default, it renders in new line for user control.
Here is my Markup
<tr>
<td>
<asp:ContentPlaceHolder ID="TitleContentPlaceHolder" runat="server">
<asp:Label ID="lblTitle" runat="server" EnableTheming="False" Font-Size="Small" ForeColor="Green"
Font-Bold="True" Style="margin-left: 18px"></asp:Label>
<asp:HyperLink ID="gotoHyperLink" Visible="false" EnableTheming="False" Font-Size="Small"
ForeColor="Green" Font-Bold="True" Style="margin-left: 2px" runat="server" NavigateUrl=""
Target="_blank">- To Wiki</asp:HyperLink>
<uc1:GoToRequestControl ID="GoToRequestControl1" runat="server" />
</asp:ContentPlaceHolder>
</td>
</tr>
I want to render the UC1 in the same line as previous two controls in Div if possible after some spacing to the right. Any fix on how to achieve this?
My User Control is designed using despite that I want it to be on same line. Here is my Usercontrol's HTML
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<asp:Panel runat="server" DefaultButton="btnGo" BackColor="Transparent">
<table style="margin-left:18px">
<tr valign="top">
<td>
<b><asp:Literal ID="Label1" runat="server" Text="Coeus Request ID: " EnableTheming="False"></asp:Literal></b>
</td>
<td>
<asp:TextBox ID="tbRequestId" runat="server" EnableTheming="false" Width="260px"></asp:TextBox>
</td>
<td>
<asp:Button ID="btnGo" runat="server" Text="Go" OnClick="btnGo_Click" OnClientClick="CheckLock();"
CausesValidation="False" UseSubmitBehavior="false" />
</td>
<td>
<asp:Label ID="lblStatus" runat="server" Text="" EnableTheming="False" ForeColor="Red"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>

Passing Eval value to C# method for shopping cart

I am creating a shopping cart web app for my class. When the user clicks on the add to cart button, I want to pass the value of the ID of each specific product to a separate method in the code behind. Not sure if my syntax is off or if this just wont work. Here is my mark up:
<asp:Button ID="AddToCart" CommandName="Add"
OnClientClick ='<%# ListView1_AddToCart(Eval("ID"))%>'
CssClass ="Button" runat="server" Text="Add to Cart" />
Here is my code behind:
public void ListView1_AddToCart(string CatID)
{cart.AddToCart(CatID);}
I keep getting various issues, but this gives me the following error:
The best overloaded method match for 'OurCats_GrumpyCats.ListView1_AddToCart(string)'
has some invalid arguments.
How can I resolve this? Is there any better way?
EDIT: Here is my mark up
<%# Page Title="All Cats" Language="C#" MasterPageFile="~/MasterPage/Layout.master" AutoEventWireup="true" CodeFile="AllCats.aspx.cs" Inherits="OurCats_GrumpyCats" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
<h1>Meet all of our kittens!</h1>
<asp:ListView ID="ListView1" runat="server" DataKeyNames="ID" DataSourceID="SqlDataSource2">
<EmptyDataTemplate>
<span>No data was returned.</span>
</EmptyDataTemplate>
<InsertItemTemplate>
<span style="">ID:
<asp:TextBox ID="IDTextBox" runat="server" Text='<%# Bind("ID") %>' />
<br />
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
Price:
<asp:TextBox ID="PriceTextBox" runat="server" Text='<%# Bind("Price") %>' />
<br />
Imgu:
<asp:TextBox ID="ImguTextBox" runat="server" Text='<%# Bind("Img") %>' />
<br />
Description:
<asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
<br />
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
<br />
<br />
</span>
</InsertItemTemplate>
<ItemTemplate>
<table class ="Table" style="border-style: solid; ">
<tr>
<td >
<a href ="Details.aspx?ID=<%# Eval("ID")%>">
<img src="../Images/<%# Eval("Img") %>" width ="200" />
</a>
</td>
<td style="width:700px; margin-left: 100px">
<asp:Label ID="Label1" runat="server" Text="Name: "></asp:Label><asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
<asp:Textbox ID="CatID" runat="server" Visible="false" Text='<%# Eval("ID")%>'></asp:Textbox>
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="Price: $"></asp:Label><asp:Label ID="PriceLabel" runat="server" Text= '<%# Eval("Price") %>'/>
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Description: "></asp:Label><asp:Label ID="DescriptionLabel" runat="server" Text= '<%# Eval("Description") %>' />
<br />
<br />
<asp:Button ID="AddToCart" CommandName="Add" OnClientClick='<%# "AddToCart(" +Eval("ID") + " );" %>' CssClass ="Button" runat="server" Text="Add to Cart" />
</td>
</tr>
</table>
</ItemTemplate>
<LayoutTemplate>
<div id="itemPlaceholderContainer" runat="server" style =" margin-left :30px;">
<span runat="server" id="itemPlaceholder" />
</div>
<div style="">
</div>
</LayoutTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:420_Project_GLConnectionString1 %>" SelectCommand="SELECT * FROM [OurCats]">
</asp:SqlDataSource>
</asp:Content>
try below code
<asp:Button ID="AddToCart" CommandName="Add"
OnClientClick ='<%# ListView1_AddToCart((string)Eval("ID"))%>'
CssClass ="Button" runat="server" Text="Add to Cart" />
OnClientClick ='<%# "ListView1_AddToCart(" +Eval("ID") + " );" %>'

Child Update Panel don't to get refresh

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

Modal Popup closes when select gridview row / ASP / AJAX / C#

I have a Modal Popup that launches from a LinkButton inside a GridView.
Inside the Modal Popup there are 3 TextBox and 3 GridView. Users select items from the GridView row which are then populated inside the text boxes.
When a users selects a GridView row, the modal popup closes. If you open the modal popup again the TextBox is populated but I need the modal popup to remain open.
Main Page Gridview
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
OnRowDataBound="GridView1_RowDataBound" CssClass="mGrid"
AlternatingRowStyle-CssClass="alt">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name"
HtmlEncode="true" />
<asp:BoundField DataField="Order" HeaderText="Order"
HtmlEncode="true" />
<asp:BoundField DataField="Drinks" HeaderText="Drinks"
HtmlEncode="true" />
<asp:BoundField DataField="Comments" HeaderText="Comments"
HtmlEncode="true" />
<asp:CommandField ShowSelectButton="true" ButtonType="Link"
Visible="false" SelectText="Enroll" />
<asp:TemplateField ItemStyle-Width="60px">
<ItemTemplate>
<asp:LinkButton ID="lnkEdit" runat="server"
Text="Add Lunch" OnClick="Edit"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
Main Page Modal Popup
<asp:Panel ID="Panel2" runat="server" class="modalPopup" Style="display: none">
<table>
<tr>
<td>
<asp:Label ID="Header" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td valign="top">
<asp:Label ID="Label1" runat="server" Text="Order"></asp:Label>
</td>
<td valign="top">
<asp:Label ID="Label2" runat="server" Text="Drinks">
</asp:Label>
</td>
<td valign="top">
<asp:Label ID="Label3" runat="server" Text="Comments">
</asp:Label>
</td>
</tr>
<tr>
<td valign="top">
<asp:TextBox ID="txtOrder" runat="server" Rows="3"
TextMode="MultiLine" Width="100%"></asp:TextBox>
</td>
<td valign="top">
<asp:TextBox ID="txtDrinks" runat="server" Rows="3"
TextMode="MultiLine"></asp:TextBox>
</td>
<td valign="top">
<asp:TextBox ID="txtComments" runat="server" Rows="3"
TextMode="MultiLine"></asp:TextBox>
<asp:TextBox ID="txtName" runat="server" Visible="false">
</asp:TextBox>
<asp:TextBox ID="txtDate" runat="server" Visible="false">
</asp:TextBox>
</td>
</tr>
<tr>
<td>
Order History
</td>
</tr>
<tr>
<td valign="top">
<asp:GridView ID="gvOrder" runat="server" CssClass="mGrid"
AlternatingRowStyle-CssClass="alt"
AutoGenerateColumns="false"
OnSelectedIndexChanged="gvOrder_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="Order" HeaderText="Order"
HtmlEncode="true" />
<asp:CommandField SelectText="Add To Order"
ShowSelectButton="True" />
</Columns>
</asp:GridView>
</td>
<td valign="top">
<asp:GridView ID="gvDrinks" runat="server" CssClass="mGrid"
AlternatingRowStyle-CssClass="alt"
AutoGenerateColumns="false"
OnSelectedIndexChanged="gvDrinks_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="Drinks" HeaderText="Drinks"
HtmlEncode="true" />
<asp:CommandField SelectText="Add To Order"
ShowSelectButton="True" />
</Columns>
</asp:GridView>
</td>
<td valign="top">
<asp:GridView ID="gvComments" runat="server" CssClass="mGrid"
AlternatingRowStyle-CssClass="alt"
AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Comments"
HeaderText="Comments"
HtmlEncode="true" />
<asp:CommandField SelectText="Add To Order"
ShowSelectButton="True" />
</Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td>
<div class="popup_Buttons">
<asp:Button ID="Okaybtn" runat="server" Text="Done"
OnClick="Save" />
<input id="Button1" type="button" value="Cancel" />
</div>
</td>
</tr>
</table>
</asp:Panel>
<asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
<cc1:ModalPopupExtender ID="popup" runat="server" DropShadow="false"
PopupControlID="Panel2" TargetControlID="btnShowPopup"
BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
Can anyone shed some light on why this happens and what I can do to get around it?
Let me know if you need to see some of the codebehind.
Thanks in advance!
Little bit late, but you can call
modalPopupExpander.Show();
Possible way for this is to register to an event of your modal-content page.

Categories

Resources