Display Pop up using nested datalist details - c#

My first 'Datalist1' retrieves some values from database i.e.,
Bus Route ID,
Vehicle number,
Trip date,
Bus source station name,
Bus Destination name
Another 'nested Datalist' which is placed inside datalist1 displays Bus icons of stages according to the number of stages between source and destination.
I succeeded to retrieving the data correctly and displayed a pop up using the above retrieved details.
<asp:DataList ID="DataList1" runat="server" RepeatColumns="1" CellSpacing="3" RepeatLayout="Table" BackColor="LightGray" OnItemDataBound="DataList1_DataBinding">
<ItemTemplate>
<table class="table">
<tr style="background-color : #b62a26; font-size:medium ; font-family:Verdana; height:40px ">
<td style="padding-left:5px">
<asp:Label ID="lblTrip" runat="server" Text="TripID:" ForeColor="White"></asp:Label>
</td>
<td style="width:900px; ">
<b> <asp:Label ID="lblTripID" runat="server" Text='<%# Eval("TripID") %>' ForeColor="White"></asp:Label></b></td>
</td>
</tr>
<tr style="background-color: white; font-size:small ; font-family:Verdana; height:60px; ">
<td colspan="2">
<b>RouteID: </b></b>
<asp:Label ID="lblRouteID" runat="server" Text='<%# Eval("RouteID") %>'></asp:Label>
<b>Vehicle NO: </b>
<asp:Label ID="lblVehicleNo" runat="server" Text='<%# Eval("VehicleNo") %>'></asp:Label>
<b>TripDate: </b>
<asp:Label ID="lblTripDate" runat="server" Text='<%# Eval("TripDate") %>'></asp:Label>
<b>From: </b>
<asp:Label ID="lblFromStage" runat="server" Text='<%# Eval("FromStage") %>'></asp:Label>
<b>To: </b>
<asp:Label ID="lblToStage" runat="server" Text='<%# Eval("ToStage") %>'></asp:Label>
</td>
</tr>
<tr style="background-color: white; font-size:small ; font-family:Verdana; height:10px ">
<td style="width:10px"></td>
<td>
<div id="activeBus" style="line-height: 0px; float: left; margin: 0px; padding: 0px; display: inline-block; vertical-align: top;">
<asp:DataList ID="innerDataList1" runat="server" RepeatColumns="10" CellSpacing="3" BackColor="white">
<ItemTemplate>
<asp:Panel ID="Panel2" runat="server" HorizontalAlign="center">
<table>
<tr style=" align-items:center ">
<td>
<asp:ImageButton ID="imgactiveBtn" runat="server" src="\images\ActiveRed.png" Width="15px" Height="15px" OnClick="imgBtn_Click" ToolTip="Track Details" />
<%-- <asp:ImageButton ID="ImageButton1" src="\images\ActiveRed.png" runat="server" Style="cursor: pointer" Width="15px" Height="15px" OnClientClick="return LoadDiv(this.src);"/> --%>
</td>
</tr>
<tr>
<td>
<b><asp:Label ID="lblStageName" runat="server" Text='<%# Eval("StageName") %>' Font-Size="XX-Small" Font-Names="Verdana" ></asp:Label></b>
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:DataList>
</div>
<div id="inactiveBus" style="line-height: 0px; float: left; margin: 0px; padding: 0px; display: inline-block; vertical-align: top;">
<asp:DataList ID="innerDataList" runat="server" RepeatColumns="10" CellSpacing="3" BackColor="white" OnItemDataBound="innerDataList_ItemDataBound">
<ItemTemplate>
<asp:Panel ID="Panel2" runat="server" HorizontalAlign="center">
<table>
<tr style=" align-items:center ">
<td>
<asp:ImageButton ID="imginactiveBtn" runat="server" src="\images\InActive.png" Width="15px" Height="15px" OnClick="imgBtn_Click" ToolTip="Not Reached yet!" />
</td>
</tr>
<tr>
<td>
<b><asp:Label ID="lblStageName" runat="server" Text='<%# Eval("StageName") %>' Font-Size="XX-Small" ForeColor="#CCCCFF"></asp:Label></b>
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:DataList>
</div>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
<div id="dialog" style="display: none">
<br />
<b>RouteID:</b> <span id="RouteID1"></span> <label id="lblEmpId"></label>
<br />
<b>TripDate:</b> <span id="TripDate1"></span> <label id="lblEmpName"></label>
<br />
<b>Stage Name:</b> <span id="StageName1"></span><label id="lblEmpLocation"></label>
<br />
<b>Scheduled Arrival:</b> <span id="Scheduled_Time1"></span>
<br />
<b>Reached On:</b> <span id="Arrival_Time1"></span>
<br /><br />
</div>
Jquery code is:
$(document).on("click", "[id*=imginactiveBtn]", function () {
$("#RouteID1").html($(".RouteID", $(this).closest("tr")).html());
$("#TripDate1").html($(".TripDate", $(this).closest("tr")).html());
$("#StageName1").html($(".StageName", $(this).closest("tr")).html());
$("#Scheduled_Time1").html($(".Scheduled_Time", $(this).closest("tr")).html());
$("#Arrival_Time1").html($(".Arrival_Time", $(this).closest("tr")).html());
// Get the Current Row and its values.
var currentRow = $(this).parents("tr");
var RId = currentRow.find("span[id*='lblRouteID']").text();
var TDate = currentRow.find("span[id*='lblTripDate']").text();
var SName = currentRow.find("span[id*='lblStageName']").text();
// Populate labels inside the dailog.
$("#lblEmpId").text(RId);
$("#lblEmpName").text(TDate);
$("#lblEmpLocation").text(SName);
$("#dialog").dialog({
title: "Track Vehicle at <em>" + SName + "</em>",
buttons: {
Ok: function () {
$(this).dialog('close');
}
},
modal: true
});
return false;
});
    
For example let us assume on 12/10/2017, 2 Trips were active with RouteID's 1 & 2, and each Routes has 3 stages.
When the first stage of route 1 is clicked Popup should display:
Route ID: Route1
TripDate: 12/10/2017
Stage Name: Stage1
When second icon is clicked Popup should should display
RouteID: Route1
TripDate: 12/10/2017
Stage: Stage2 and so on...
Similarly when Stages of Route2 is clicked
Route ID: Route2
TripDate: 12/10/2017
Stage Name: Stage1
and when he clicks second stage of Route 2
Route ID: Route2
TripDate: 12/10/2017
Stage Name: Stage2 and so on.....
But Popup displays:
RouteID: Route1Route2
TripDate: 12/10/201712/10/2017
StageName: Stage1Stage2Stage3Stage1Stage2Stage3
for all the 3 stages of Route1 and for all the 3 stages of Route2.
How can i resolve this. Where am i doing it wrong?

Related

OnTextChanged does not trigger after required attribute validation

I have an update Panel with some textbox and I'm trying to replace the requiredfieldvalidators by using the required attribute on the textboxes which makes everything much cleaner. Only first textbox has required for testing purposes.
<asp:UpdatePanel runat="server">
<ContentTemplate>
<table style="border-collapse: separate; border-spacing: 8px;">
<tbody>
<tr>
<td style="float: right;">
<asp:Label ID="lblRefCliente" runat="server" Text="Referência Cliente " ForeColor="#142658" Style="font-weight: bold;"></asp:Label><span style="color: red;">* </span>
</td>
<td>
<asp:TextBox ID="txtRefClient" CssClass="txtStyle" runat="server" required></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvRefClient" runat="server" ForeColor="red" ControlToValidate="txtRefClient" ErrorMessage=""></asp:RequiredFieldValidator>
</td>
<td style="float: right;">
<asp:Label ID="lblRefInterna" runat="server" Text="Referência Interna " ForeColor="#142658" Style="font-weight: bold;"></asp:Label><span style="color: red;">* </span>
</td>
<td>
<asp:TextBox ID="txtRefInterna" CssClass="txtStyle" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvRefInterna" runat="server" ForeColor="red" ControlToValidate="txtRefInterna" ErrorMessage=""></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td style="float: right;">
<asp:Label ID="lblIndice" runat="server" Text="Indíce " ForeColor="#142658" Style="font-weight: bold;"></asp:Label><span style="color: red;">* </span>
</td>
<td>
<asp:TextBox ID="txtIndice" CssClass="txtStyle" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvIndice" runat="server" ForeColor="red" ControlToValidate="txtIndice" ErrorMessage=""></asp:RequiredFieldValidator>
</td>
<td style="float: right;">
<asp:Label ID="lblProject" runat="server" Text="Projecto " ForeColor="#142658" Style="font-weight: bold;"></asp:Label><span style="color: red;">* </span>
</td>
<td>
<asp:TextBox ID="txtProject" CssClass="txtStyle" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvProject" runat="server" ForeColor="red" ControlToValidate="txtProject" ErrorMessage=""></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td style="float: right;">
<asp:Label ID="lblCadMensal" runat="server" Text="Cadência Mensal " ForeColor="#142658" Style="font-weight: bold;"></asp:Label><span style="color: red;">* </span>
</td>
<td>
<asp:TextBox ID="txtCadMensal" CssClass="txtStyle" AutoPostBack="true" runat="server" OnTextChanged="txtCadMensal_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvCadMensal" runat="server" ForeColor="red" ControlToValidate="txtCadMensal" ErrorMessage=""></asp:RequiredFieldValidator>
</td>
<td style="float: right;">
<asp:Label ID="lblDesenho" runat="server" Text="Desenho " ForeColor="#142658" Style="font-weight: bold;"></asp:Label><span style="color: red;">* </span>
</td>
<td>
<asp:TextBox ID="txtDesenho" CssClass="txtStyle" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvDesenho" runat="server" ForeColor="red" ControlToValidate="txtDesenho" ErrorMessage=""></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td style="float: right;">
<asp:Label ID="lblNumCOMDEV" runat="server" Text="Nº de COMDEV " ForeColor="#142658" Style="font-weight: bold;"></asp:Label><span style="color: red;">* </span>
</td>
<td>
<asp:TextBox ID="txtNumCOMDEV" CssClass="txtStyle" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvNumCOMDEV" runat="server" ForeColor="red" ControlToValidate="txtNumCOMDEV" ErrorMessage=""></asp:RequiredFieldValidator>
</td>
<td style="float: right;">
<asp:Label ID="lblNumFormas" runat="server" Text="Nº Formas de Lançamento " ForeColor="#142658" Style="font-weight: bold;"></asp:Label><span style="color: red;">* </span>
</td>
<td>
<asp:TextBox ID="txtNumFormas" CssClass="txtStyle" runat="server" AutoPostBack="true" OnTextChanged="txtNumFormas_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvNumFormas" runat="server" ForeColor="red" ControlToValidate="txtNumFormas" ErrorMessage=""></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td style="float: right;">
<asp:Label ID="lblCapacidadeReal" runat="server" Text="Capacidade Real(métodos) " ForeColor="#142658" Style="font-weight: bold;"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtCapacidadeReal" CssClass="txtStyle" runat="server"></asp:TextBox>
</td>
</tr>
</tbody>
</table>
</ContentTemplate>
</asp:UpdatePanel>
Now the problem is that i Have this textbox txtNumComps that creates some dynamic textboxes for some input and does it OnTextChanged event and is doing it asynch. The problem is that when the validation from the required attribute fires, the OnTextChanged does not trigger, only triggers the 2nd i write something. I don't see what can cause this problem. if someone could help i'd appreciate.
<asp:UpdatePanel runat="server" ID="NumComps">
<ContentTemplate>
<table>
<tr>
<td>
<asp:Label ID="lblNumComps" runat="server" Text="Nº de Componentes " ForeColor="#142658" Style="font-weight: bold;"></asp:Label><span style="color: red; margin-right: 5px;"> * </span>
</td>
<td>
<asp:TextBox ID="txtNumComps" runat="server" AutoPostBack="True" OnTextChanged="txtNumComps_TextChanged"></asp:TextBox>
</td>
<td>
<asp:CustomValidator ID="cvNumComps" runat="server" ForeColor="red" ErrorMessage="" ControlToValidate="txtNumComps" ClientValidationFunction="NumpCompsValidator"></asp:CustomValidator>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txtNumComps" EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>

DataBinding: 'System.Data.DataRow' does not contain a property with the name 'RoomType'

i have datatable i want to filter it to select only the rows when the avalibality not = null,datatable contains null rows i want to select only not null roows from the table,i want to filter the data table because the itemdatabound bind the null rowws it is display in the user interface with null .
if (dtRoomDetails != null && dtRoomDetails.Rows.Count != 0)
{
var expr = "[Availability2] > '0' ";//Availability2 this is the cloumn name i want to select only all values without null values.
dtlRoomsPrice2.DataSource = dtRoomDetails.Select(expr);
dtlRoomsPrice2.DataBind();//error is here when bind data
}
<asp:DataList ID="dtlRoomsPrice2" Visible="false" orizontalAlign="center" runat="server"
ShowFooter="False" ShowHeader="False" Width="700px" OnItemDataBound="dtlRoomsDetails_ItemDataBound">
<ItemTemplate>
<div class="bordcolrrr">
<table id="RoomList" style="width: 700px;" border="0" align="left">
<%
RowCount++;
if (UsingRows.IndexOf(RowCount.ToString()) != -1)
{
%>
<tr>
<td width="215" class="bordercolor" style="">
<table border="0" id="LeftTable" width="200" align="left">
<tr>
<td class="shbe_h2" colspan="2" style="position: relative;top: -16px;left: 12px;">
<asp:Label ID="Label4" runat="Server" CssClass="shbe_label" Text='<%# DataBinder.Eval(Container, "DataItem.RoomType") %>'
Width="170px"></asp:Label>
<asp:Label ID="LabelGr" Visible="false" runat="Server" CssClass="shbe_label" Text='<%# DataBinder.Eval(Container, "DataItem.GuaranteeRequired") %>'></asp:Label>
</td>
<td style="width: 55px;">
<a class="thumbnail" href="#thumb">
<asp:Image Width="60" ID="RoomImg" runat="server" Height="60" ImageUrl='<%# DataBinder.Eval(Container, "DataItem.ImageRoomCode") %>' />
<span>
<asp:Image ID="Image1" Width="370" Height="246" runat="server" ImageUrl='<%# DataBinder.Eval(Container, "DataItem.ImageRoomCode") %>' /></span>
</a>
</td>
<td style="vertical-align: bottom; text-align: left;">
<asp:Label ID="LblRoomDesc" runat="Server" CssClass="shbe_h2" Text='<%# DataBinder.Eval(Container, "DataItem.RoomText") %>'
Visible="false"></asp:Label>
</td>
</tr>
</table>
</td>
<td class="bordercolor" width="100" style="">
<table border="0" id="singleTbl" class="singtbl" width="70" align="left" runat="server" style="display: none;">
<tr>
<td width="35"></td>
<td class="shbe_h2" style="padding-left: 5px">
<asp:Button ID="btnSSelect" runat="server" CssClass="btnselect" Text='<%$Resources:Resource,Select %>'
CommandName='<%#Eval("IDRoom")+ "-" + Eval("Availability2") %>' CommandArgument="tblBookNow"
OnClick="btnSelectRoom_Click2" Visible="false" />
<asp:Label ID="Label2" runat="server" Visible="false" Text='<%#Eval("IDRoom")+ "-" + Eval("Availability2")%>'></asp:Label>
<asp:DropDownList ID="DropDownList1" Width="45px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true" runat="server" >
</asp:DropDownList>
</td>
</tr>
<tr>
<td width="35" style="font-weight: bold; font-size: 12px; text-align: center;">
<br />
</td>
<td style="padding-left: 10px">
<asp:Label ID="lblSRRate" runat="Server" CssClass="shbe_h2" Text='<%# DataBinder.Eval(Container, "DataItem.STotalRate2") %>'
ForeColor="Red"></asp:Label> <span class="shbe_h2" style="display:none;"><%=strCurrency %></span></td>
</tr>
<tr>
<td></td>
<td style="height: 30px; text-align: center">
<asp:Label ID="lblSRCounter" ForeColor="White" runat="server" BorderStyle="None"
BackColor="Transparent" BorderColor="Transparent" CssClass="room-counter" Text="0"
Width="36px" Height="29px" Visible="false"></asp:Label>
</td>
</tr>
<%} %>
</table>

Ajax Modal Popup not closing on TextChange event in IE

In my page, I have a text_change event that is fired and it goes to the database, looks up a value, then sets textbox and hidden field. After those fields are set, I display modal popup to validate the values returned. The issue is once the popup is displayed, it takes about 30 seconds before the close button is active. I have narrowed it down to the text_change event because I have several text_change events on the page which show a modal popup for validation and I get the same behavior for all of them. I do not get the same behavior when I trigger the validation summary on the page from a button_click event I am not sure why there is a delay and how to get past this issue.
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage/SiteMaster.master" AutoEventWireup="true"
CodeBehind="PoReceiving.aspx.cs" Inherits="ChatWirelessWebOLPApp.PoReceiving" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<table width="100%">
<tr>
<td class="page-heading" colspan="3" style="height: 20px;">
PO Receiving
<hr style="width: 99%; margin: 5px 0 10px 5px; padding: 0; background-color: #000;" />
</td>
</tr>
</table>
<div id="dvBody" style="width: 100%; float: left; margin: -24px 0 0 0; padding: 0;">
<div style="width: 950px; margin: 0 auto 0 auto; font-family: Calibri; font-size: small;">
<div style="width: 100%; float: left; margin: 30px 0 0 0; display: block;" id="Div2">
</div>
<div style="width: 100%; float: left; margin: -25px 0 0 0; display: block;" id="dvRo">
<div id="dv_RmaInfo" style="width: 950px; margin: 10px auto 0 auto; border: 1px solid #ccc;">
<table style="width: 90%;" align="center">
<tr>
<td colspan="2" align="center" style="height: 30px;">
<asp:Label ID="lblMsg" runat="server" CssClass="ErrorMsg" />
</td>
<tr>
<td align="right">
<asp:Label ID="lblpallet" runat="server" Width="150px" Text="Pallet Nbr: " Style="margin-right: 5px;"></asp:Label>
</td>
<td align="left">
<asp:TextBox ID="txtPalletId" runat="server" Width="150px" />
<asp:RequiredFieldValidator ID="rfvPkNbr" runat="server" Font-Bold="true" Font-Size="Medium"
ErrorMessage="Pallet Nbr Required" ForeColor="#FF3300" ControlToValidate="txtPalletId"
Display="Dynamic" ValidationGroup="group1">*</asp:RequiredFieldValidator>
<asp:Button ID="btnSearch" runat="server" Text="Search" Width="100px" Style="width: 100px;
padding: 2px 0; cursor: pointer; margin-left: 5px; background: #0071bd; border: 1px solid #ccc;
color: #fff; font-family: Arial; font-size: 12px;" OnClick="btnSearch_Click" />
</td>
</tr>
</table>
<asp:HiddenField ID="HiddenField1" runat="server" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="pnlPopup1"
TargetControlID="HiddenField1" OkControlID="btnDlgOK1" BackgroundCssClass="modalPopUp"
DropShadow="true">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="pnlPopup1" runat="server" CssClass="popUp" Width="300px">
<br />
<table align="center">
<tr>
<td align="center">
<asp:ValidationSummary HeaderText="The following errors occurred:" ID="ValidationSummary1"
ValidationGroup="group1" Font-Names="Calibri" Font-Size="Medium" Visible="true"
runat="server" ForeColor="Black" align="left" />
</td>
</tr>
<tr>
<td align="center">
<asp:Label ID="lblPopUpMsg1" runat="server" Font-Names="Calibri" Font-Size="Medium"
Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td align="center">
<br />
<asp:Button ID="btnDlgOK1" CssClass="button" runat="server" Style="width: 100px;
padding: 2px 0; cursor: pointer; margin-left: 5px; height: 23px; background: #0071bd;
border: 1px solid #ccc; color: #fff; font-family: Arial; font-size: 12px;" Text="Close" />
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
</table>
</asp:Panel>
</div>
<%--<br />
<br />--%>
<asp:Panel ID="panel1" runat="server" Visible="false">
<br />
<div id="Div3" style="width: 950px; margin: 10px auto 0 auto; border: 1px solid #ccc;">
<table cellpadding="2" cellspacing="0">
<tr>
<td align="right">
<asp:Label ID="Label6" runat="server" Text="Shopping Cart:" />
</td>
<td align="left">
<asp:TextBox ID="txtShoppingCart" runat="server" /><asp:RequiredFieldValidator ID="rfvtxtShoppingCart"
runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="Shopping Cart Required"
ForeColor="#FF3300" ControlToValidate="txtShoppingCart" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="Label7" runat="server" Text="Enter Ship to Code:" />
</td>
<td align="left">
<asp:TextBox ID="txtShipToCode" runat="server" Width="65px" AutoPostBack="true" OnTextChanged="txtShipToCode_TextChanged" /><asp:RequiredFieldValidator
ID="rfvtxtShipToCode" runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="Ship Code Required"
ForeColor="#FF3300" ControlToValidate="txtShipToCode" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>
</td>
<td align="left" colspan="4">
<asp:TextBox ID="txtMarket" runat="server" Enable="false" Width="250px" />
<asp:HiddenField ID="hdnLocId" runat="server" />
<%--<asp:DropDownList
ID="ddlMarket" runat="server" Visible="false" /><asp:RequiredFieldValidator ID="rfvtxtMarket"
runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="Select a Market" InitialValue="none"
ForeColor="#FF3300" ControlToValidate="ddlMarket" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>--%>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="Label8" runat="server" Text="Customer Part Nbr/Mfg Part Nbr:" />
</td>
<td align="left">
<asp:TextBox ID="txtPartNbr" runat="server" AutoPostBack="true" OnTextChanged="txtPartNbr_TextChanged" /><asp:RequiredFieldValidator
ID="rfvtxtPartNbr" runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="Part Nbr Required"
ForeColor="#FF3300" ControlToValidate="txtPartNbr" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" valign="top">
<asp:Label ID="Label9" runat="server" Text="Mfg Part Nbr:" />
</td>
<td align="left" valign="top">
<asp:TextBox ID="txtMfgPartNbr" runat="server" Enabled="false" />
</td>
<td align="right" valign="top">
<asp:Label ID="label11" runat="server" Text="Serialized:" />
</td>
<td align="left" valign="top">
<asp:TextBox ID="txtSerialized" runat="server" Enabled="false" Width="46px" />
</td>
<td align="right" valign="top">
<asp:Label ID="label10" runat="server" Text="Part Description:" />
</td>
<td align="left" valign="top">
<asp:TextBox ID="txtDescription" runat="server" Enabled="false" Height="51px" Width="257px"
TextMode="MultiLine" />
</td>
</tr>
<tr id="rowSerialized" runat="server" visible="false">
<td align="right">
<asp:Label ID="label12" runat="server" Text="TMO Asset Nbr:" />
</td>
<td align="left">
<asp:TextBox ID="txtAssetNbr" runat="server" /><asp:RequiredFieldValidator ID="rfvTxtAssetNbr"
runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="T-Mobile Asset Tag Required"
ForeColor="#FF3300" ControlToValidate="txtAssetNbr" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>
</td>
<td align="right">
<asp:Label ID="label13" runat="server" Text="Serial Nbr:" />
</td>
<td align="left">
<asp:TextBox ID="txtSerialNbr" runat="server" Width="102px" /><asp:RequiredFieldValidator
ID="rfvTxtSerialNbr" runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="Serial Nbr Required"
ForeColor="#FF3300" ControlToValidate="txtSerialNbr" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>
</td>
<td align="right">
<asp:Label ID="label17" runat="server" Text="Putaway Bin:" />
</td>
<td align="left">
<asp:TextBox ID="txtBin1" runat="server" />
</td>
</tr>
<tr id="rowNonSerialized" runat="server" visible="false">
<td align="right">
<asp:Label ID="label14" runat="server" Text="Quantity:" />
</td>
<td align="left">
<asp:TextBox ID="txtQty" runat="server" ontextchanged="txtQty_TextChanged" AutoPostBack="true" /><asp:RequiredFieldValidator ID="rfvTxtQty"
runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="Quantity Required"
ForeColor="#FF3300" ControlToValidate="txtQty" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>
</td>
<td align="right">
<asp:Label ID="label16" runat="server" Text="Putaway Bin:" />
</td>
<td align="left" colspan="2">
<asp:TextBox ID="txtBin2" runat="server" Width="97px" />
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="label15" runat="server" Text="Nbr of Labels:" />
</td>
<td align="left">
<asp:TextBox ID="txtNbrOfLabels" runat="server" /><asp:RequiredFieldValidator ID="rfvTxtNbrOfLabels"
runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="Number of labels to print Required"
ForeColor="#FF3300" ControlToValidate="txtNbrOfLabels" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>
</td>
<td align="right">
<asp:Label ID="label18" runat="server" Text="Clear Shopping Cart:" />
</td>
<td>
<asp:DropDownList ID="ddlCloseShoppingCart" runat="server">
<asp:ListItem Selected="True" Text="NO" Value="no" />
<asp:ListItem Text="YES" Value="yes" />
</asp:DropDownList>
</td>
<td align="right">
<asp:Label ID="label19" runat="server" Text="Clear Pallet:" />
</td>
<td>
<asp:DropDownList ID="ddlClosePallet" runat="server">
<asp:ListItem Selected="True" Text="NO" Value="no" />
<asp:ListItem Text="YES" Value="yes" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="6" align="center">
<br />
<asp:Button ID="btnSave" runat="server" Text="Save" Style="width: 100px;
padding: 2px 0; cursor: pointer; margin-left: 5px; height: 23px; background: #0071bd;
border: 1px solid #ccc; color: #fff; font-family: Arial; font-size: 12px;" OnClick="btnSave_Click" />
<asp:Button
ID="btnReset" Style="width: 100px; padding: 2px 0; cursor: pointer;
margin-left: 5px; height: 23px; background: #0071bd; border: 1px solid #ccc;
color: #fff; font-family: Arial; font-size: 12px;" runat="server" Text="Reset"
OnClick="btnReset_Click" />
</td>
</tr>
</table>
<asp:HiddenField ID="HiddenField2" runat="server" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender2" runat="server" PopupControlID="pnlPopup2"
TargetControlID="HiddenField2" OkControlID="btnDlgOK2" BackgroundCssClass="modalPopUp"
DropShadow="true">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="pnlPopup2" runat="server" CssClass="popUp" Width="300px">
<br />
<table align="center">
<tr>
<td align="center">
<asp:ValidationSummary HeaderText="The following errors occurred:" ID="ValidationSummary2"
ValidationGroup="group2" Font-Names="Calibri" Font-Size="Medium" Visible="true"
runat="server" ForeColor="Black" align="left" />
</td>
</tr>
<tr>
<td align="center">
<asp:Label ID="lblPopUpMsg2" runat="server" Font-Names="Calibri" Font-Size="Medium"
Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td align="center">
<br />
<asp:Button ID="btnDlgOK2" CssClass="button" runat="server" Style="width: 100px;
padding: 2px 0; cursor: pointer; margin-left: 5px; height: 23px; background: #0071bd;
border: 1px solid #ccc; color: #fff; font-family: Arial; font-size: 12px;" Text="Close" />
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
</table>
</asp:Panel>
<asp:HiddenField ID="HiddenField3" runat="server" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender3" runat="server" PopupControlID="pnlPopup3" TargetControlID="HiddenField3"
BackgroundCssClass="modalPopUp" DropShadow="true">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="pnlPopup3" runat="server" CssClass="popUp" Width="300px">
<br />
<table align="center">
<tr><td align="center">
<asp:ValidationSummary HeaderText="Form Validation:" ID="ValidationSummary3" ValidationGroup = "group2"
Font-Names="Calibri" Font-Size="Medium" Visible="true" runat="server" ForeColor="Black" align="left"/>
</td></tr>
<tr><td>
<asp:Label ID="lblPopUpMsg3" runat="server" Font-Names="Calibri" Font-Size="Medium"
Visible="False"></asp:Label>
</td> </tr>
<tr>
<td align="center">
<br />
<asp:Button ID="btnDlgOK3" runat="server" CssClass="button" OnClick="btnDlgOK3_Click"
Style="width: 100px; padding: 2px 0; cursor: pointer; margin-left: 5px; height: 23px;
background: #0071bd; border: 1px solid #ccc; color: #fff; font-family: Arial;
font-size: 12px;" Text="Continue" />
<asp:Button ID="btnDlgCancel3" runat="server" CssClass="button" OnClick="btnDlgCancel3_Click"
Style="width: 100px; padding: 2px 0; cursor: pointer; margin-left: 5px; height: 23px;
background: #0071bd; border: 1px solid #ccc; color: #fff; font-family: Arial;
font-size: 12px;" Text="Cancel" />
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
</table>
</asp:Panel>
</div>
</asp:Panel>
</div>
</div>
</div>
<input type="hidden" id="printConfirm" runat="server" />
<input type="hidden" id="printString" runat="server" />
<input type="hidden" id="nbrLabels" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="BusyIndicator" runat="server" DynamicLayout="true" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<div class="progress">
<asp:Image ID="Image2" runat="server" ImageUrl="~/images/ajax-loader.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</asp:Content>
protected void txtShipToCode_TextChanged(object sender, EventArgs e)
{
if (txtShipToCode.Text != "" && !string.IsNullOrEmpty(txtShipToCode.Text))
{
PoReceivingDBHandler po = new PoReceivingDBHandler();
DataTable location = new DataTable();
string msg = string.Empty;
if (!po.GetShipToLocation(txtShipToCode.Text.Trim().ToUpper(), ref location, ref msg))
{
ErrorLogging log = new ErrorLogging();
log.LogError("PoReceiving.aspx.cs-txtShipToCode_TextChanged", "DB ERror", string.Empty, string.Empty, msg, HttpContext.Current.Session["LoginID"].ToString());
ValidationSummary2.Visible = false;
ModalPopupExtender2.Show();
lblPopUpMsg2.Text = msg;
lblPopUpMsg2.Visible = true;
return;
}
else
{
if (location.Rows.Count > 0)
{
txtMarket.Text = location.Rows[0]["LOC_DESC"].ToString();
hdnLocId.Value = location.Rows[0]["LOC_ID"].ToString();
//ValidationSummary2.Visible = false;
ModalPopupExtender2.Show();
lblPopUpMsg2.Text = "Please verify Market matches code entered.";
lblPopUpMsg2.Visible = true;
//return;
}
else
{
txtMarket.Text = string.Empty;
//ValidationSummary2.Visible = false;
ModalPopupExtender2.Show();
lblPopUpMsg2.Text = "No market was found for the code entered.\n\rPlease check and re-enter the code.";
lblPopUpMsg2.Visible = true;
}
}
}
}

linkbutton are not posting back in asp.net

I have many linkbutton placed on a webform everything working correctly til yesterday. But now now my ajax extenders are not working and linkbuttons are posting back.
some of my code is
<table width="460px">
<tr>
<td colspan="2"
style=" color: #C48239; font-style: normal; font-size: 18px; font-family: 'Bookman Old Style'; text-align:center;height:22px;">
Manage Your Profile</td>
</tr>
<tr>
<td>
<asp:LinkButton ID="lnk_per_pro" runat="server" CssClass="linkButton"
PostBackUrl="~/User/Edit_profile.aspx">Edit Personal Profile</asp:LinkButton> </td>
<td>
<asp:LinkButton ID="lnk_par_pro" runat="server" CssClass="linkButton">Edit Partner's Profile</asp:LinkButton></td>
</tr>
<tr>
<td>
<asp:LinkButton ID="lnk_con_det" runat="server" CssClass="linkButton"
PostBackUrl="~/User/Edit_profile.aspx">Edit Contect Details</asp:LinkButton></td>
<td>
<asp:LinkButton ID="lnk_add_photos" runat="server" CssClass="linkButton">Add Photos</asp:LinkButton></td>
</tr>
<tr>
<td>
<asp:LinkButton ID="lnk_hob" runat="server" CssClass="linkButton"
PostBackUrl="~/User/Edit_profile.aspx">Edit Hobbies and Interests</asp:LinkButton></td>
<td>
<asp:LinkButton ID="lnk_del_pro" runat="server" CssClass="linkButton">Remove/Delete Profile</asp:LinkButton></td>
</tr>
</table></center>
</div>
</div><!-- div 2 end-->
<div id="div3">
<div id="inbox1"><b>About Myself</b>
</div>
<div id="inbox2">Partner Prefrence
</div>
</div>
<div id="div4">
<div id="indiv4"><b>Basics Information</b>
<div id="edit4">
<asp:LinkButton ID="lnk_edit" runat="server" CssClass="link"
PostBackUrl="~/User/Edit_profile.aspx"> Edit</asp:LinkButton> <img src="images/edit.png" alt="" />
</div>
</div>
<div id="indiv24">
<div id="lt"><table class="style1" >
<tr>
<td style="color: #666666; width: 180px">
Age</td>
<td style="width: 180px">
<asp:Label ID="lbl_age2" runat="server" Text="Label"></asp:Label>
</td></tr><tr>
<td style="color: #666666; width: 180px">
Mobile Number</td>
<td>
<asp:Label ID="lbl_mob2" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td style="color: #666666; width: 180px">
Height</td>
<td style="width: 180px">
<asp:Label ID="lbl_height2" runat="server" Text="Label"></asp:Label>
</td></tr><tr>
<td style="color: #666666; width: 180px">
Email Id</td>
<td>
<asp:Label ID="lbl_eml2" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td style="color: #666666; width: 180px">
Marital Status</td>
<td style="width: 180px">
<asp:Label ID="lbl_mar_sts2" runat="server" Text="Label"></asp:Label>
</td></tr>
</table></div>
a link is shown on hover of linkbutton
javascript:webforms_DoPostbackWithOption:(NewPostBackoption("","false",true,"false"));
Do you have any validation controls inside application , check once by setting the Cause validation = false to link button control .
Some times your system has changed to old time(like one year back) also the link buttons won't redirect
There may be validation controls inside application , check once by setting the Cause validation = false to link button control .

Field Validator Fires undesirably

I have a page with the following mark up
<%# Page Title="" Language="C#" MasterPageFile="~/CaseAdmin.master" AutoEventWireup="true" CodeBehind="AddExhibit.aspx.cs" Inherits="Prototype5.AddExhibit" %>
<h2 class="style2">
<strong><span style="color: #FFFFFF">Add Exhibit
Form</span></strong></h2>
<div style="width: 600px">
<table style="width: 303px" align="left">
<tr>
<td class="style26" style="background-color: #666666">
<p class="style5" style="color: #000000; background-color: #666666;">
<strong style="background-color: #666666">Select Existing Case ID:
</strong>
</p></td>
<td class="" style="background-color: #C0C0C0" align="left">
<asp:DropDownList ID="DropDownListcaseid" runat="server"
onselectedindexchanged="DropDownListcaseid_SelectedIndexChanged">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="DropDownListcaseid"
ErrorMessage="Please select a valid case id from the dropdown menu"
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style4" colspan="2">
</td>
</tr>
</table>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CMSSQL3ConnectionString1 %>"
SelectCommand="SELECT [CaseID] FROM [Cases]"></asp:SqlDataSource>
</div>
<div style="width: 603px; height: 75px; ">
<table style="height: 66px; width: 598px; top: 277px; left: 268px;"
align="left">
<tr>
<td class="bold"
style="color: #000000; background-color: #666666; width: 127px;">
<strong>Exhibit Type</strong></td>
<td class="bold" style="background-color: #666666; width: 228px;">
<span style="color: #000000">Exhibit Image</td>
<td class="bold" style="background-color: #666666; width: 111px;">
<span style="color: #000000">Stored Location</span></td>
<td class="bold" style="background-color: #666666; color: #000000;">
Officer ID</span></td>
</tr>
<tr>
<td class="style32" style="background-color: #C0C0C0; width: 127px;">
<asp:DropDownList ID="exhibitTypeDropDownList" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Hard Disk</asp:ListItem>
<asp:ListItem>Pen Drive</asp:ListItem>
<asp:ListItem>Laptop</asp:ListItem>
<asp:ListItem>Palm Devce</asp:ListItem>
<asp:ListItem>Mobile Phone</asp:ListItem>
<asp:ListItem>Tablet PC</asp:ListItem>
<asp:ListItem>Pager</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="exhibitTypeDropDownList"
ErrorMessage="Please Enter the type of exhibit. eg. Harddisk"
ForeColor="Red" ondisposed="addExhibitButton_Click">*</asp:RequiredFieldValidator>
</td>
<td class="style28" style="background-color: #C0C0C0; width: 228px;">
<asp:FileUpload ID="exhibitImageFileUpload" runat="server" />
</td>
<td class="style20" style="background-color: #C0C0C0; width: 111px;">
<asp:DropDownList ID="storedLocationDropDownList" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>B-15/4</asp:ListItem>
<asp:ListItem>B-10/1</asp:ListItem>
<asp:ListItem>B-5/4</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="storedLocationDropDownList"
ErrorMessage="Please enter a valid stored location" ForeColor="Red"
ondisposed="addExhibitButton_Click">*</asp:RequiredFieldValidator>
</td>
<td class="style30" style="background-color: #C0C0C0">
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="officersSqlDataSource" DataTextField="PoliceID"
DataValueField="PoliceID" Width="79px" Height="26px">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="DropDownList1"
ErrorMessage="Please select a valid Officer id from the dropdown list"
ForeColor="Red" ondisposed="addExhibitButton_Click">*</asp:RequiredFieldValidator>
</td>
</tr>
</table>
</div>
<div style="width: 609px; height: 23px;">
</div>
<div style="margin-top:12px; width: 232px; text-align:left; font-size:1.3em;">
<asp:SqlDataSource ID="officersSqlDataSource"
runat="server"
ConnectionString="<%$ ConnectionStrings:CMSSQL3ConnectionString1 %>"
SelectCommand="SELECT PoliceID FROM PoliceOfficers"></asp:SqlDataSource>
<table align="left">
<tr>
<td align="center">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="Red"
HeaderText="The following errors occured." />
</td>
</tr>
</table>
</div>
<div style="margin-top:12px; width: 456px;">
<table style="width: 450px" align="left">
<tr>
<td align="center" colspan="3">
<asp:Label ID="messageLabel" runat="server" BackColor="White" ForeColor="Red"
Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td align="center" style="width: 96px">
<asp:Button ID="cancelButton" runat="server" Text="Cancel"
onclick="cancelButton_Click" height="26px" width="101px" />
</td>
<td style="width: 237px">
</td>
<td align="center">
<asp:Button ID="addExhibitButton" runat="server" Text="Add Exhibit"
onclick="addExhibitButton_Click" />
</td>
</tr>
</table>
</div>
and the following interface look
I wish to perform validation on the page only when the "add exhibit button" is clicked. so in my code behind, i used an "if(page.isvalid)" to check for page validation when the button is clicked. However any other button i click fires the validation as well... I presume its because every button click tries to load a page and that calls the validator to action. how do i allow work around the validation such that, only the " add exhibit button" triggers the page validation?
You need to set the ValidationGroup property on the button and the validator. That way you can control what validation takes place.
The ValidationGroup property is an arbitrary tag that you can add to your validators and buttons to group them into logical units. So in your case, I would do this:
For your validators that are relevant for the add exhibit action.
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" ValidationGroup="AddExhibit" ...
For your button that triggers your add exhibit.
<asp:Button ID="addExhibitButton" ValidationGroup="AddExhibit"

Categories

Resources