Field Validator Fires undesirably - c#

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"

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>

colspan screwing up css asp.net table

I created a table to organize my items on a page. The page is an edit page for a property.
I used colspan to expand rows and put a textbox within rows and set the textbox wdith to 100%, However, the textbox width still only takes the space of 1 column not 3 columns like I expected here is the code
<table align="left" style="width: 100%; float: left" class="FormFormatTable">
<tr>
<td style="width: 10%; height: 60px">Alert Name</td>
<td colspan="3" style=" ">
<asp:TextBox CssClass="inputBoxes" ID="txtBox_alertName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 10%; height: 60px;">Alert</td>
<td style="height: 60px; ">
<asp:DropDownList ID="ddl_AlertTime" runat="server">
<asp:ListItem Value="1">After</asp:ListItem>
<asp:ListItem Value="0">Immediately</asp:ListItem>
</asp:DropDownList>
</td>
<td style="height: 60px; ">
<input id="demo_vertical0" type="number"/></td>
<td style="height: 60px">
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Seconds</asp:ListItem>
<asp:ListItem>Minutes</asp:ListItem>
<asp:ListItem>Hours</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 10%">Severity</td>
<td style=" height: 60px"" >
<asp:DropDownList ID="ddl_Severity" runat="server">
<asp:ListItem Value="1">After</asp:ListItem>
<asp:ListItem Value="0">Immediately</asp:ListItem>
</asp:DropDownList>
</td>
<td style=""> </td>
<td> </td>
</tr>
<tr style="height:60px">
<td style="width: 10%">Receipients</td>
<td colspan="3" style="">
<asp:TextBox CssClass="inputBoxes" ID="txtBox_Receipients" runat="server"></asp:TextBox>
</td>
</tr>
<tr style="height:60px">
<td style="width: 10%">Subject Title</td>
<td colspan="3" style="">
<asp:TextBox CssClass="inputBoxes" ID="txtBox_SubjectTitle" runat="server"></asp:TextBox>
</td>
</tr>
<tr style="height:60px">
<td style="width: 10%">Alert Messsage</td>
<td colspan="3" style="">
<asp:TextBox CssClass="inputBoxes" ID="txtBox_AlertMessage" runat="server"></asp:TextBox>
</td>
</tr>
<tr style="height:60px">
<td style="width: 10%; ">Notification Window</td>
<td style=" ">
<asp:TextBox CssClass="inputBoxes" ID="txtBox_NotificationWindow" runat="server"></asp:TextBox>
</td>
<td style=" "></td>
<td style="height: 60px"></td>
</tr>
<tr style="height:60px">
<td style="width: 10%; ">Notification Frequency</td>
<td style=" ">
<input id="demo_vertical" type="number"/>
</td>
<td style=" "></td>
<td style="height: 60px"></td>
</tr>
<tr style="height:60px">
<td style="width: 10%">Fields to Display in Details</td>
<td colspan="3" style="">
<asp:TextBox CssClass="inputBoxes" ID="txtBox_SubjectTitle3" runat="server"></asp:TextBox>
</td>
</tr>
</table>
css is simple just this
.inputBoxes {
width: 100%;
}
why is this?
a screenshot of my page on my computer
In you HTML
the Alert Name , Receipients ,Subject Title ,Alert Messsage ,Fields to Display in Details TextBoxs take 3 columns .
Notification Window take one columns because you don't set colspan
you must add colspan="3" to your td of notfication
<td colspan="3" style=" ">
<asp:TextBox CssClass="inputBoxes" ID="txtBox_NotificationWindow" runat="server"></asp:TextBox>
</td>
You have an extra quote in the following line (the cell definition that contains your ddl_Severity control).
<td style=" height: 60px"" >
Maybe remove this quote, and see if that fixes it.

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;
}
}
}
}

Textfield clears after calendar control postback

I have 3 text fields on my page and one calendar control. After I fill in the 3 text boxes, then click a date on the calendar control, the bottom textfield clears out, losing its value. The other 2 text boxes have their values available and do not get cleared. The textboxes all have the same properties, but I can't figure out how to keep the value in the third textbox.
<table class="auto-style2" align="center">
<tr>
<td class="auto-style4" style="text-align: right">Project Name:</td>
<td style="text-align: left">
<asp:TextBox ID="TxtProjectName" runat="server" height="32px" width="211px" MaxLength="50" OnTextChanged="TxtProjectName_TextChanged" onKeyUp="Count(this,50)" onChange="Count(this,50)" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TxtProjectName" ErrorMessage="Field is required"></asp:RequiredFieldValidator>
</td>
</tr>
</table>
<table class="auto-style2" align="center">
<tr>
<td class="auto-style4" style="text-align: right">Project Description:</td>
<td style="text-align: left">
<asp:TextBox ID="TxtDescription" runat="server" height="45px" width="211px" TextMode="MultiLine" OnTextChanged="TxtDescription_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TxtDescription" ErrorMessage="Field is required"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style4" style="text-align: right">Contact Name:</td>
<td style="text-align: left">
<asp:TextBox ID="TxtContactName" runat="server" Width="203px" OnTextChanged="TxtContactName_TextChanged" Height="16px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TxtContactName" ErrorMessage="Field is required"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style5">Business Area:</td>
<td class="auto-style3">
<asp:DropDownList ID="DDLBusinessArea" runat="server" style="text-align: left">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style4" style="text-align: right">Priority:</td>
<td style="text-align: left">
<asp:DropDownList ID="DDLPriority" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style4" style="text-align: right">Desired Completion Date:</td>
<td style="text-align: left">
<asp:Calendar ID="Calendar1" runat="server">
<SelectedDayStyle Font-Bold="True" />
<TodayDayStyle ForeColor="#3333FF" />
</asp:Calendar>
</td>
</tr>
Its the TxtContactName that clears.

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 .

Categories

Resources