Display:block doesn't work [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I'm so tired because this problem for a long day.
The code below seems to be so long, but it's not hard to understand what I did in that code. Hope you can give me a solution.
I have a panel ID="ASPxPanel2" with stype set to display:none.
After I click on button New --> the panel will be displayed.
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<table>
<tr>
<td>
<dx:ASPxPanel ID="ASPxPanel2" runat="server" Width="700px" Height="150px" RenderMode="Table" CssClass="display_none">//set to display:none here
<PanelCollection>
<dx:PanelContent ID="PanelContent1" runat="server" SupportsDisabledAttribute="True">
<table>
<tr>
<td colspan=4>
<asp:Label ID="LabelError" runat="server" ForeColor="red" Text="">
</asp:Label>
</td
</tr>
<tr>
<td>Đối tượng</td>
<td>
<dx:ASPxComboBox ID="MA_DOI_TUONG" runat="server" ClientIDMode="AutoID"
ValueType="System.String">
</dx:ASPxComboBox>
</td>
<td>Loại</td>
<td >
<dx:ASPxComboBox ID="MA_LOAI" runat="server" ClientIDMode="AutoID"
ValueType="System.String">
</dx:ASPxComboBox>
</td>
<td class="style6">
</td>
<td rowspan=5>
MoreFileUpload
<div style="display: "";" id="div0">
<dx:ASPxTextBox ID="TFileUpload0" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload0" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div1">
<dx:ASPxTextBox ID="TFileUpload1" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload1" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div2">
<dx:ASPxTextBox ID="TFileUpload2" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload2" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div3">
<dx:ASPxTextBox ID="TFileUpload3" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload3" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div4">
<dx:ASPxTextBox ID="TFileUpload4" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload4" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div5">
<dx:ASPxTextBox ID="TFileUpload5" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload5" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div6">
<dx:ASPxTextBox ID="TFileUpload6" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload6" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div7">
<dx:ASPxTextBox ID="TFileUpload7" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload7" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div8">
<dx:ASPxTextBox ID="TFileUpload8" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload8" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div9">
<dx:ASPxTextBox ID="TFileUpload9" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload9" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div10">
<dx:ASPxTextBox ID="TFileUpload10" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload10" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div11">
<dx:ASPxTextBox ID="TFileUpload11" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload11" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div12">
<dx:ASPxTextBox ID="TFileUpload12" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload12" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div13">
<dx:ASPxTextBox ID="TFileUpload13" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload13" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div14">
<dx:ASPxTextBox ID="TFileUpload14" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload14" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div15">
<dx:ASPxTextBox ID="TFileUpload15" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload15" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div16">
<dx:ASPxTextBox ID="TFileUpload16" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload16" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div17">
<dx:ASPxTextBox ID="TFileUpload17" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload17" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div18">
<dx:ASPxTextBox ID="TFileUpload18" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload18" runat="server" accept="png|jpg" Width="180px" size=32 />
</div>
<div style="display: none;" id="div19">
<dx:ASPxTextBox ID="TFileUpload19" runat="server" ClientIDMode="AutoID"
Width="180px" Height="16px">
</dx:ASPxTextBox>
<asp:FileUpload ID="FileUpload19" runat="server" accept="png|jpg" Width="180px" size=27 />
</div>
<div style="text-align: left; width: 263px;" id="divShow">
<a id="linkMore" href="javascript:void(0)" onclick="javascript:ShowHideFileUpload(this.id)">
+ Add More ...</a></div>
<br /><br />
</td>
</tr>
<tr>
<td>Title</td>
<td class="style5" colspan=3>
<dx:ASPxTextBox ID="TITLE" runat="server" ClientIDMode="AutoID"
Width="300px" Height="16px" >
</dx:ASPxTextBox>
</td>
</tr>
<tr><td>Content</td>
<td class="style2" colspan=3>
<FTB:FreeTextBox id="ftCONTENT" runat="server"
ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu,FontForeColorPicker,FontBackColorsMenu,FontBackColorPicker|Bold,Italic,Underline,JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,
Cut,Copy,Paste,Delete;Undo,Redo,InsertTable,EditTable;InsertTableRowAfter,InsertTableRowBefore,DeleteTableRow;InsertTableColumnAfter,InsertTableColumnBefore,DeleteTableColumn"
EditorBorderColorDark="DarkGray" EditorBorderColorLight="DarkGray"
Width="100%" GutterBorderColorDark="Gray" GutterBorderColorLight="White"
ToolbarStyleConfiguration="Office2000" AutoGenerateToolbarsFromString="True" JavaScriptLocation="InternalResource" />
</td>
</tr>
<tr>
<td>FileAttach</td>
<td colspan=3>
<asp:FileUpload ID="PATH" runat="server"
size=40 Width="300px"/></td></tr>
<tr align=center>
<td colspan=5 align=center>
<dx:ASPxButton ID="ASPxButton1" runat="server" ClientIDMode="AutoID"
style="text-align: center" Text="Thêm" HorizontalAlign="Center"
OnClick="btnInsert_Click">
</dx:ASPxButton>
</td>
</tr>
</table>
</dx:PanelContent>
</PanelCollection>
</dx:ASPxPanel>
</td></tr>
</dx:ASPxPanel>
</td>
</tr>
</table>
</asp:Panel> //end ASPXPanel2
<table>
<tr>
td><dx:ASPxPanel ID="ASPxPanel1" runat="server" Width="200px" RenderMode="Table">
</dx:ASPxPanel>
</td>
<td>
<asp:Button ID="btnNew" runat="server" Text="NEW" OnClick="btnNew_Click" />
</td>
</tr>
</table>
In the code behind:
protected void btnNew_Click(object sender, EventArgs e)
{
ASPxPanel2.Attributes.Add("Sytle", "display:block");
//do something more
}
I've added ASPxPanel2.Attributes.Add("Sytle", "display:block"); when btnNew_Click fired, but the ASPxPanel2 isn't displayed.
Does the display:block not work?? Help!!!
UPDATE:
I've found my mistake, typo: "Style" not "Sytle"
But it has a new problem.
There still have a ASPxPanel1 in my webpage. When I set the ASPxPanel2 display:block as default, the Panel1 will be displays below the Panel2. But when I set Panel2 display:none and then set it display:block again in code behind---> the Panel2 display cover Panel1.
Help!!!
I've updated my code above. Please take a look!

Typo
ASPxPanel2.Attributes.Add("Sytle", "display:block");
Should read
ASPxPanel2.Attributes.Add("Style", "display:block");

Related

Ajax Autocomplete Not Pulling Data

Okay, I have searched and searched, and methods that work for others don't seem to be working for me. I am trying to get AJAX's autocomplete to work but I have had no luck. Eventually, I want a textbox with autocomplete, pulling data from a sqldatasource, but first, I just want it to work. So, I have tried a simple implementation that I found on this website. The individual who used this code got it to work using this code, but my textbox functions just like an ordinary textbox (with no autocomplete features). I am fairly new to web dev and would appreciate any assistance. Thanks.
UPDATE:
Okay...I tried making a new, simple, webpage and tried to do the autocomplete thing again. I get this bizarre result (Single characters that make no sense):
Incorrect Autocomplete Image
aspx code
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string[] GetCompletionList(string prefixText, int count)
{
string[] results = { "test", "test", "test" };
return results;
}
cs. code
<asp:Label ID="FieldLabel" Text="Label:" runat="server"></asp:Label>
<asp:TextBox ID="InputField" runat="server"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
ID="Autocompleter"
TargetControlID="InputField"
ServiceMethod="GetCompletionList"
ServicePath="~/BatchReleaseStatus.aspx"
MinimumPrefixLength="1"
CompletionInterval="1000"
runat="server">
</ajaxToolkit:AutoCompleteExtender>
Site.Master
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="CrownLabsDbFrontEnd.SiteMaster" %>
<!DOCTYPE html>
<html lang="en">
<head runat="server">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><%: Page.Title %> - Crown Labs Quality Database</title>
<asp:PlaceHolder runat="server">
<%: Scripts.Render("~/bundles/modernizr") %>
</asp:PlaceHolder>
<webopt:bundlereference runat="server" path="~/Content/css" />
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<style type="text/css">
.auto-style1 {
width: 131px;
height: 91px;
}
</style>
</head>
<body>
<form runat="server">
<asp:ScriptManager runat="server" EnablePageMethods="true" EnableScriptGlobalization="true">
<Scripts>
<%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%>
<%--Framework Scripts--%>
<asp:ScriptReference Name="MsAjaxBundle" />
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="bootstrap" />
<asp:ScriptReference Name="respond" />
<asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<%--Site Scripts--%>
</Scripts>
</asp:ScriptManager>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" runat="server" href="~/"><img alt="Crown Labs Logo" class="auto-style1" src="file:///C:/Users/bcampbell/Pictures/logo_crown.gif" /></a> </div>
<div class="navbar-collapse collapse" style="padding-top:50px">
<ul class="nav navbar-nav">
<li><a runat="server" href="~/">Home</a></li>
<li><a runat="server" href="~/BatchReleaseStatus">Batch Release Status</a></li>
<li><a runat="server" href="~/CAPA">CAPA</a></li>
<li><a runat="server" href="~/Investigations">Investigations</a></li>
<li><a runat="server" href="~/Validations">Validations</a></li>
<li><a runat="server" href="~/Administration">Administration</a></li>
</ul>
<asp:LoginView runat="server" ViewStateMode="Disabled">
<AnonymousTemplate>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server" href="~/Account/Register">Register</a></li>
<li><a runat="server" href="~/Account/Login">Log in</a></li>
</ul>
</AnonymousTemplate>
<LoggedInTemplate>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server" href="~/Account/Manage" title="Manage your account">Hello, <%: Context.User.Identity.GetUserName() %> !</a></li>
<li>
<asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" />
</li>
</ul>
</LoggedInTemplate>
</asp:LoginView>
</div>
</div>
</div>
<div class="container body-content">
<hr />
<footer>
<p>© <%: DateTime.Now.Year %> - My ASP.NET Application<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</footer>
</div>
</form>
<script src="Scripts/currentClass.js"></script>
</body>
</html>
BatchReleaseStatus.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="BatchReleaseStatus.aspx.cs" Inherits="CrownLabsDbFrontEnd.BatchReleaseStatus" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<p><%--The following <p>'s keep the content from going under the Master Header --%>
<p> <p>
<asp:Button ID="btnShow_ClientSide" runat="server"
Text="show client side" OnClientClick="return false" />
<asp:Button ID="btnShow_ServerSide" runat="server"
Text="show server side" OnClick="btnShow_ServerSide_Click" />
<ajaxToolKit:ModalPopupExtender ID="mdlPopup" runat="server"
TargetControlID="btnShow_ClientSide"
PopupControlID="pnlPopup" CancelControlID="btnHide_ClientSide"
BackgroundCssClass="modalBackground" />
<asp:Panel ID="pnlPopup" runat="server"
BackColor="#CCFFFF" BorderColor="#FF6699" style="text-align: left">
Batch Number:
<asp:TextBox ID="BatchNumTextBox" runat="server"></asp:TextBox>
Part:
<br />
<asp:Button ID="btnHide_ClientSide" runat="server"
Text="hide client side" OnClientClick="return false" OnClick="btnHide_ClientSide_Click" />
<asp:Button ID="btnHide_ServerSide" runat="server"
Text="hide server side" OnClick="btnHide_ServerSide_Click" />
</asp:Panel>
<asp:Label ID="FieldLabel" Text="Label:" runat="server"></asp:Label>
<asp:TextBox ID="InputField" runat="server"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
ID="Autocompleter"
TargetControlID="InputField"
ServiceMethod="GetCompletionList"
ServicePath="~/BatchReleaseStatus.aspx"
MinimumPrefixLength="1"
CompletionInterval="1000"
runat="server">
</ajaxToolkit:AutoCompleteExtender>
<p>
<asp:SqlDataSource ID="BatchReleaseData" runat="server" ConnectionString="<%$ ConnectionStrings:TestDBConnectionString %>" SelectCommand=<%# ViewState["stringInViewState"] %>></asp:SqlDataSource>
<%--Set up the stationary header for the primary GridView --%>
<div style =" background-color:navy;
height:30px;width:450px; margin-left:auto; margin-right:auto">
<table cellspacing="0" cellpadding = "0" border="0" id="tblHeader"
style="font-family:Arial;font-size:10pt;width:438px;color:white;
border-collapse:collapse;height:100%;">
<tr>
<%--Sets up the link buttons that will populate the header and allow sorting --%>
<td style ="width:165px;text-align:center">
<asp:LinkButton ID="MfgDatLnkBtn" runat="server" OnClick="MfgDatLnkBtn_Click" ForeColor="White">Manufacture Date</asp:LinkButton>
</td>
<td style ="width:140px;text-align:center">
<asp:LinkButton ID="BatchLnkBtn" runat="server" OnPreRender="LinkButtons_PreRender" OnClick="BatchLnkBtnClck">Batch ID</asp:LinkButton>
</td>
<td style ="width:135px;text-align:center">
<asp:LinkButton ID="DescriptionLnkBtn" runat="server" OnPreRender="LinkButtons_PreRender" OnClick="DescriptionLnkBtn_Click">Description</asp:LinkButton>
</td>
<td style ="width:140px;text-align:center">
<asp:LinkButton ID="BaseLnkBtn" runat="server" OnPreRender="LinkButtons_PreRender" OnClick="BaseLnkBtn_Click">Base</asp:LinkButton>
</td>
</tr>
</table>
</div>
<div style="margin-left:auto; margin-right:auto; width:450px; overflow:auto; height:450px; border:solid">
<table class="nav-justified">
<tr>
<td style="text-align: center">
<div style="margin-left:auto; margin-right:auto">
<asp:GridView ID="BatchReleaseGV" DataSourceId="BatchReleaseData" DataKeyNames="Mfg_Date" AutoGenerateColumns="false" ShowHeader="false"
runat="server" OnSelectedIndexChanged="BatchReleaseGV_SelectedIndexChanged" OnRowDataBound="BatchReleaseGV_RowDataBound">
<Columns>
<asp:BoundField ItemStyle-Width = "150px" DataField="Mfg_Date" HeaderText="Manufacture Date" DataFormatString="{0:MM/dd/yyyy }" HtmlEncode=false >
<ItemStyle Font-Size="Large" />
</asp:BoundField>
<asp:BoundField ItemStyle-Width = "150px" DataField="Batch" HeaderText="Batch ID"
FooterText="">
<FooterStyle CssClass="FooterStyle" />
</asp:BoundField >
<asp:BoundField ItemStyle-Width = "150px" DataField="Product" HeaderText="Description" />
<asp:BoundField ItemStyle-Width = "150px" DataField="Base" HeaderText="Base (if applicable)" />
</Columns>
</asp:GridView>
</div>
</td>
</tr>
</table>
</div>
<p>
<asp:SqlDataSource ID="BatchReleaseDataMfgDateOnly" runat="server" ConnectionString="<%$ ConnectionStrings:TestDBConnectionString %>" SelectCommand="SELECT DISTINCT CONVERT(date,[Mfg Date]) AS Mfg_Date FROM [Batch Info] ORDER BY [Mfg_Date] DESC"></asp:SqlDataSource>
<asp:SqlDataSource ID="BatchReleaseDataBatchOnly" runat="server" ConnectionString="<%$ ConnectionStrings:TestDBConnectionString %>" SelectCommand="SELECT DISTINCT [Batch] FROM [Batch Info] ORDER BY [Batch]"></asp:SqlDataSource>
<asp:SqlDataSource ID="BatchReleaseDataProductOnly" runat="server" ConnectionString="<%$ ConnectionStrings:TestDBConnectionString %>" SelectCommand="SELECT DISTINCT [Product] FROM [Batch Info] ORDER BY [Product]"></asp:SqlDataSource>
<asp:SqlDataSource ID="BatchReleaseDataBaseOnly" runat="server" ConnectionString="<%$ ConnectionStrings:TestDBConnectionString %>" SelectCommand="SELECT DISTINCT [Base] FROM [Batch Info] ORDER BY [Base]"></asp:SqlDataSource>
</p>
<table class="nav-justified">
<tr>
<td class="text-right">Manufacturing Date:
</td>
<td class="text-left">
<asp:TextBox ID="MfgDateTxtBx" runat="server"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="MfgDateTxtBx_CalendarExtender" runat="server" TargetControlID="MfgDateTxtBx" />
<asp:RegularExpressionValidator ID="MfgDateValidator" runat="server" ControlToValidate="MfgDateTxtBx" ErrorMessage="Invalid Date Entered" ValidationExpression="^((0?[13578]|10|12)(-|\/)(([1-9])|(0[1-9])|([12])([0-9]?)|(3[01]?))(-|\/)((19)([2-9])(\d{1})|(20)([01])(\d{1})|([8901])(\d{1}))|(0?[2469]|11)(-|\/)(([1-9])|(0[1-9])|([12])([0-9]?)|(3[0]?))(-|\/)((19)([2-9])(\d{1})|(20)([01])(\d{1})|([8901])(\d{1})))$" Font-Bold="True" ForeColor="Red"></asp:RegularExpressionValidator>
</td>
<td> Batch ID:
<asp:DropDownList ID="BatchDropDown" runat="server" DataSourceID="BatchReleaseDataBatchOnly" DataValueField="Batch">
</asp:DropDownList>
</td>
<td> Description:
<asp:DropDownList ID="ProductDropDown" runat="server" DataSourceID="BatchReleaseDataProductOnly" DataValueField="Product">
</asp:DropDownList>
</td>
<td>Base: <asp:DropDownList ID="BaseDropDown" runat="server" DataSourceID="BatchReleaseDataBaseOnly" DataValueField="Base">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="text-right">To (Optional): </td>
<td style="text-align: left">
<asp:TextBox ID="DateRangeTxtBx" runat="server"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="DateRangeTxtBx_CalendarExtender" runat="server" TargetControlID="DateRangeTxtBx" />
<asp:RegularExpressionValidator ID="MfgDateRangeValidator" runat="server" ControlToValidate="DateRangeTxtBx" ErrorMessage="Invalid Date Entered" ValidationExpression="^((0?[13578]|10|12)(-|\/)(([1-9])|(0[1-9])|([12])([0-9]?)|(3[01]?))(-|\/)((19)([2-9])(\d{1})|(20)([01])(\d{1})|([8901])(\d{1}))|(0?[2469]|11)(-|\/)(([1-9])|(0[1-9])|([12])([0-9]?)|(3[0]?))(-|\/)((19)([2-9])(\d{1})|(20)([01])(\d{1})|([8901])(\d{1})))$" Font-Bold="True" ForeColor="Red" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:CompareValidator id="MfgDateRangeComparator" runat="server"
ControlToCompare="MfgDateTxtBx" cultureinvariantvalues="true"
display="Dynamic" enableclientscript="true"
ControlToValidate="DateRangeTxtBx"
ErrorMessage="Start date must be earlier than finish date"
type="Date" setfocusonerror="true" Operator="GreaterThanEqual"
text="Start date must be earlier than finish date" Font-Bold="True" ForeColor="Red"></asp:CompareValidator>
</td>
<td>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="TextBox3_AutoCompleteExtender" runat="server" TargetControlID="TextBox3" MinimumPrefixLength="1" ServiceMethod="GetCompletionList" ServicePath="BatchReleaseStatus.aspx">
</ajaxToolkit:AutoCompleteExtender>
</td>
<td> </td>
<td> </td>
</tr>
</table>
<p>
<asp:Button ID="submitBtn" runat="server" OnClick="submitBtn_Click" Text="Submit" />
</p>
<p>
</p>
</asp:Content>
In order to use System.Web.Services.WebMethod in a codebehind file from an aspx Site, this method must be static. Also your scriptmanager need to have "EnablePageMethods=true" setted.
=> This approach is called PageMethods.
I think it's better to use WebApi instead of PageMethods, you can easily integerate this into your asp.net project. Here you will find a startpoint.
Getting started with Web-API
PageMethod-Test:
<script type="text/javascript">
function Test() {
PageMethods.Test(function(result){alert(result);});
}
[System.Web.Services.WebMethod]
public static string Test()
{
return "Hello StackOverflow";
}

How to allow user to search without refreshing the page

I have the following three dropdownlist and a button which gives a result based on the selected criterias:
<asp:DropDownList ID="slcLocation" runat="server" ClientIDMode="Static">
</asp:DropDownList>
<br />
<br /><br />
<asp:DropDownList ID="slcSpecialty" runat="server" ClientIDMode="Static">
</asp:DropDownList>
<br /><br />
<asp:DropDownList ID="slcGender" runat="server" ClientIDMode="Static">
<asp:ListItem Text="Any Gender" Value="" Selected="True" />
<asp:ListItem Text="Male" Value="1" />
<asp:ListItem Text="Female" Value="2" />
</asp:DropDownList>
<asp:Button ID="btnGoAll" Text="Search All" OnClick="btnGoAll_Click" runat="server" ClientIDMode="Static" />
The first two dropdownlist populates using code-behind function.
How can I allow the user to select all three options and hit the search button to display the result without refreshing the page?
I tried something like this:
<div style="width: 390px; margin: 0 auto;">
<asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:DropDownList AutoPostBack="True" ID="slcLocation" runat="server" ClientIDMode="Static" style="width: 365px;" class="default" AppendDataBoundItems="true">
</asp:DropDownList>
<br /><br />
<asp:DropDownList AutoPostBack="True" ID="slcSpecialty" runat="server" ClientIDMode="Static" style="width: 365px;" class="default" AppendDataBoundItems="true">
</asp:DropDownList>
<br /><br />
<asp:DropDownList AutoPostBack="True" ID="slcGender" runat="server" ClientIDMode="Static" style="width: 365px;" class="default" AppendDataBoundItems="true">
<asp:ListItem Text="Any Gender" Value="" Selected="True" />
<asp:ListItem Text="Male" Value="1" />
<asp:ListItem Text="Female" Value="2" />
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="slcLocation" />
</Triggers>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="slcSpecialty" />
</Triggers>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="slcGender" />
</Triggers>
</asp:UpdatePanel>
</div>
<br /><br />
<div style="width: 390px; margin: 0 auto;">
<asp:HyperLink class="loginButton" style="padding: 10px; float: right;" runat="server" ID="aSearchSubmit" ClientIDMode="Static" OnClick="btnGoAll_Click" Text="Search" />
</div>
I update my Repeater with the data retrieved from the search:
<div style="width: 100%;">
<asp:Repeater runat="server" ID="rptContent">
<HeaderTemplate>
<table border="0" ID="tblInfo" style="background: #43A79A; width: 100%;" ClientIDMode="Static">
<tr>
<td>Physician Name</td>
<td>Image</td>
<td>Gender</td>
<td>Office1</td>
<td>Office2</td>
<td>Office3</td>
<td>Office4</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("Physician Name").ToString() %></td>
<td><img src="www.site.com/<%# Eval("Image").ToString() %>" /></td>
<td><%# Eval("Gender").ToString() %></td>
<td><%# Eval("Office1").ToString() %></td>
<td><%# Eval("Office2").ToString() %></td>
<td><%# Eval("Office3").ToString() %></td>
<td><%# Eval("Office4").ToString() %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
When I click on the button, nothing happens.
How can I resolve the issue?
I think what do you want is this.
You need set how updatePanel´s trigger the button.
The part of page what do you want update need to be inside the updatepanel.
The javascript will catch DropDownList changes, and after all three DropDownList were changed the postback will be raised like if you was clicked in button
aspx
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<script>
var slcLocationSelect = false;
var slcSpecialtySelect = false;
var slcGenderSelect = false;
$(document).ready(function () {
$("#<%=slcLocation.ClientID %>").change(function () { changeDropDown(this) });
$("#<%=slcSpecialty.ClientID %>").change(function () { changeDropDown(this) });
$("#<%=slcGender.ClientID %>").change(function () { changeDropDown(this) });
});
function changeDropDown(sender) {
if ($(event.target).attr('id') == $("#<%=slcLocation.ClientID %>").attr('id')) {
slcLocationSelect = true;
}
if ($(event.target).attr('id') == $("#<%=slcSpecialty.ClientID %>").attr('id')) {
slcSpecialtySelect = true;
}
if ($(event.target).attr('id') == $("#<%=slcGender.ClientID %>").attr('id')) {
slcGenderSelect = true;
}
if (slcLocationSelect && slcSpecialtySelect && slcGenderSelect) {
slcLocationSelect = false;
slcSpecialtySelect = false;
slcGenderSelect = false;
__doPostBack("<%=LinkButton1.ClientID %>", "");
}
}
</script>
<div style="width: 390px; margin: 0 auto;">
<asp:DropDownList ID="slcLocation" runat="server" ClientIDMode="Static" Style="width: 365px;"
class="default" AppendDataBoundItems="true">
</asp:DropDownList>
<br />
<br />
<asp:DropDownList ID="slcSpecialty" runat="server" ClientIDMode="Static" Style="width: 365px;"
class="default" AppendDataBoundItems="true">
</asp:DropDownList>
<br />
<br />
<asp:DropDownList ID="slcGender" runat="server" ClientIDMode="Static" Style="width: 365px;"
class="default" AppendDataBoundItems="true">
<asp:ListItem Text="Any Gender" Value="" Selected="True" />
<asp:ListItem Text="Male" Value="1" />
<asp:ListItem Text="Female" Value="2" />
</asp:DropDownList>
<br />
<br />
<div style="width: 390px; margin: 0 auto;">
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Find</asp:LinkButton>
</div>
<asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<div style="width: 100%;">
<asp:Repeater runat="server" ID="rptContent">
<HeaderTemplate>
<table border="0" id="tblInfo" style="background: #43A79A; width: 100%;" clientidmode="Static">
<tr>
<td>
Physician Name
</td>
<td>
Image
</td>
<td>
Gender
</td>
<td>
Office1
</td>
<td>
Office2
</td>
<td>
Office3
</td>
<td>
Office4
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%# Eval("Physician Name").ToString() %>
</td>
<td>
<img src="www.site.com/<%# Eval("Image").ToString() %>" />
</td>
<td>
<%# Eval("Gender").ToString() %>
</td>
<td>
<%# Eval("Office1").ToString() %>
</td>
<td>
<%# Eval("Office2").ToString() %>
</td>
<td>
<%# Eval("Office3").ToString() %>
</td>
<td>
<%# Eval("Office4").ToString() %>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="LinkButton1" />
</Triggers>
</asp:UpdatePanel>
</div>
cs
protected void LinkButton1_Click(object sender, EventArgs e)
{
Label1.Text = slcGender.SelectedItem.ToString();
}

Losing file in a file upload control in update panel c# asp.net

I have a page where I am using 3 update panels and all the update panels are working well. In one of the update panels, I have a button which on click changes label text but the problem is that on if post back happens in any of the update panels file upload loses its file.
All the update panels are used to update separate sections of page. No update panel is nested. The file upload is outside; it is not in any of the update panels but it is still losing its file.
<%# Control Language="C#" AutoEventWireup="true" CodeFile="WalkInControl.ascx.cs"
Inherits="Modules_WalkInControl" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxtoolkit" %>
<asp:Panel ID="Panel1" runat="server" Font-Size="13px" Width="670">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers ="true" UpdateMode="Conditional">
<ContentTemplate>
<div class="formfieldset" style="margin-bottom: 40px;">
<div class="formrow">
<div class="paymentfrmlabels">
Check In :</div>
<div class="paymentfrmtxtbox">
<asp:TextBox ID="txtCheckIn" runat="server" Width="153px"></asp:TextBox>
<asp:ImageButton ID="imgbtnCalendar1" runat="server" ImageUrl="~/App_Themes/Default/images/ico-calendar.gif"
CausesValidation="false" Width="20" Height="20" />
<ajaxtoolkit:CalendarExtender ID="CalendarExtender2" runat="server" Format="dd/MM/yyyy"
TargetControlID="txtCheckIn" PopupButtonID="imgbtnCalendar1" />
</div>
<div class="paymentfrmvalidation">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="[*]"
ControlToValidate="txtCheckIn" Display="Dynamic" ValidationGroup="a"></asp:RequiredFieldValidator>
</div>
</div>
<div class="formrow">
<div class="paymentfrmlabels">
Check Out:
</div>
<div class="paymentfrmtxtbox">
<asp:TextBox ID="txtCheckOut" runat="server" Width="153px"></asp:TextBox>
<asp:ImageButton ID="imgbtnCalendar" runat="server" ImageUrl="~/App_Themes/Default/images/ico-calendar.gif"
CausesValidation="false" ImageAlign="Top" Width="20" Height="20" />
<ajaxtoolkit:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd/MM/yyyy"
TargetControlID="txtCheckOut" PopupButtonID="imgbtnCalendar" />
</div>
<div class="paymentfrmvalidation">
<asp:RequiredFieldValidator ID="valStartDate" runat="server" ErrorMessage="[*]" ControlToValidate="txtCheckOut"
Display="Dynamic" ValidationGroup="a"></asp:RequiredFieldValidator>
</div>
</div>
<div class="formrow">
<div class="paymentfrmlabels">
Room Type :
</div>
<div class="paymentfrmtxtbox">
<asp:DropDownList ID="drpRoomtype" runat="server" Width="172px" AutoPostBack="True"
OnSelectedIndexChanged="drpRoomtype_SelectedIndexChanged" AppendDataBoundItems="True">
</asp:DropDownList>
</div>
</div>
<div class="formrow">
<div class="paymentfrmlabels">
Plan :
</div>
<div class="paymentfrmtxtbox" style="height: 25px;">
<asp:DropDownList ID="drpPlan" Width="172px" AutoPostBack="True"
runat="server" onselectedindexchanged="drpPlan_SelectedIndexChanged1">
</asp:DropDownList>
</div>
</div>
<div class="formrow" style="height: 75px;">
<div class="paymentfrmlabels">
Room :
</div>
<div class="paymentfrmtxtbox">
<asp:ListBox ID="lstRooms" runat="server" Width="172px" SelectionMode="Multiple">
</asp:ListBox>
</div>
<div class="paymentfrmvalidation">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="lstRooms"
ErrorMessage="[*]" ValidationGroup="b"></asp:RequiredFieldValidator>
</div>
<div class="paymentfrmvalidation">
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<img src="../Images/loading_sm.gif" border="0" alt="">
</ProgressTemplate>
</asp:UpdateProgress>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="drpRoomtype"
ErrorMessage="[*]" ValidationGroup="a"></asp:RequiredFieldValidator>
</div>
</div>
<div class="formrow">
<div class="paymentfrmlabels">
Adults :
</div>
<div class="paymentfrmtxtbox" style="width: 50px; height: 25px;">
<asp:DropDownList ID="drpAdults" Width="50px" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="drpAdults_SelectedIndexChanged" AppendDataBoundItems="True">
</asp:DropDownList>
</div>
<div class="paymentfrmlabels" style="width: 65px;">
Children :
</div>
<div class="paymentfrmtxtbox" style="width: 50px; height: 25px;">
<asp:DropDownList ID="drpChildren" Width="50px" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="drpChildren_SelectedIndexChanged">
</asp:DropDownList>
</div>
</div>
<div class="formrow">
<div class="paymentfrmlabels">
Rate :</div>
<div class="paymentfrmtxtbox">
<asp:TextBox ID="txtRate" Width="153px" runat="server"></asp:TextBox>
</div>
<div class="paymentfrmvalidation">
<%--<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtRate"
ErrorMessage="Invalid Format" ValidationExpression="^(-)?\d+(\.\d\d)?$" ValidationGroup="a"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtRate"
ErrorMessage="Rate Required" ValidationGroup="a"></asp:RequiredFieldValidator></div>--%>
</div>
</div> <div align="center"> <asp:Label ID="lblRoomMsg" runat="server" ForeColor="Red"></asp:Label></div>
<div class="formrow">
<div class="paymentfrmlabels">
Advance Pay:
</div>
<div class="paymentfrmtxtbox" style="height: 25px;">
<asp:TextBox ID="txtAdvance" runat="server" Width="153px">0.0</asp:TextBox>
</div>
</div>
<div class="formrow" style="text-align: right;">
<asp:LinkButton ID="lnkAdd" CssClass="btn" runat="server" Width="60px" OnClick="lnkAdd_Click1">ADD</asp:LinkButton>
</div>
<div class="formrow" style="text-align:center;">
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtCheckOut"
ControlToValidate="txtCheckIn" Operator="LessThanEqual" Type="Date" ForeColor="Red" ErrorMessage="CheckIn Must Be Before CheckOut"
Display="Dynamic" ValidationGroup="a"/>
</div>
<div class="formrow" style="height: auto; margin-top: 20px; width: 430px;">
<asp:GridView ID="gvAddedRooms" runat="server" CssClass="active-grid" AutoGenerateColumns="False"
DataKeyNames="ID" Height="18px" Width="100%" OnRowDeleting="gvAddedRooms_RowDeleting">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="RoomTypeX" HeaderText="RoomType" />
<asp:BoundField DataField="RoomX" HeaderText="RoomX" />
<asp:BoundField DataField="Rate" HeaderText="Rate" DataFormatString="{0:f}" />
<asp:BoundField DataField="Adults" HeaderText="Adults" />
<asp:BoundField DataField="Children" HeaderText="Children" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
</div>
<div style="float:left;"> <asp:Label ID="Label1" runat="server" Text="Total Charge : " Font-Bold="true" ForeColor ="Blue" style="font-size:19px;"></asp:Label><asp:Label ID="lblTotalAmount" runat="server" Text=""></asp:Label>
</div>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="gvAddedRooms" />
<asp:PostBackTrigger ControlID="drpRoomtype" />
<asp:PostBackTrigger ControlID="drpPlan" />
<asp:PostBackTrigger ControlID="lnkAdd" />
<asp:PostBackTrigger ControlID="lstRooms" />
<asp:PostBackTrigger ControlID="drpAdults" />
<asp:PostBackTrigger ControlID="drpChildren" />
<asp:PostBackTrigger ControlID="btnRemoveFilename1" />
</Triggers>
</asp:UpdatePanel>
<%--<div class="formrow" style="text-align: right;">
<asp:UpdatePanel ID="UpdatePanel3" UpdateMode ="Conditional" runat="server">
<ContentTemplate >
Agency :
<asp:DropDownList ID="drpChannel" runat="server" Width="172px" AutoPostBack="True"
Height="32px" >
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="drpChannel"
/>
<asp:AsyncPostBackTrigger ControlID="lnkNewChannel" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:LinkButton ID="lnkNewChannel" runat="server" >New Channel</asp:LinkButton>
</div> --%>
<div class="newsubheadingsearchqueryresults" style="width: 685px;">
<h3>
Customer Details</h3>
<span class="requiredExample">[ * ] = Required Information</span></div>
<div class="formfieldset" style="margin-bottom: 40px;">
<div class="formrow">
<div class="paymentfrmlabels">
Paying Customer :</div>
<div class="paymentfrmtxtbox">
<asp:TextBox ID="txtCustomerName" Width="153px" runat="server"></asp:TextBox>
</div>
<div class="paymentfrmvalidation">
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtCustomerName"
ErrorMessage="[*]" ValidationExpression="^[a-zA-Z''-'\s]{1,40}$"
ValidationGroup="a" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtCustomerName"
ValidationGroup="a" ErrorMessage="[*]" Display="Dynamic"></asp:RequiredFieldValidator>
</div>
</div>
<div class="formrow">
<div class="paymentfrmlabels">
Customer Type :</div>
<div class="paymentfrmtxtbox">
<asp:DropDownList ID="drpCustomerType" Width="153px" runat="server">
<asp:ListItem Text="Person" Value="Person"></asp:ListItem>
<asp:ListItem Text="Company" Value="Company"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="formrow">
<div class="paymentfrmlabels">
E-Mail :
</div>
<div class="paymentfrmtxtbox">
<asp:TextBox ID="txtEmail" Width="153px" runat="server"></asp:TextBox>
</div>
<div class="paymentfrmvalidation">
</div>
</div>
<div class="formrow">
<div class="paymentfrmlabels">
Phone No :
</div>
<div class="paymentfrmtxtbox">
<asp:TextBox ID="txtPhone" runat="server" Height="23px" Width="153px"></asp:TextBox>
</div>
<div class="paymentfrmvalidation">
<asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ErrorMessage="Invalid format"
Display="Dynamic" ValidationExpression="^[0-9]*$" ControlToValidate="txtPhone"
ValidationGroup="a"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtPhone"
Display="Dynamic" ValidationGroup="a" ErrorMessage="[*]"></asp:RequiredFieldValidator>
</div>
</div>
<div class="formrow" style="height: 130px;">
<div class="paymentfrmlabels">
Address:</div>
<div class="paymentfrmtxtbox">
<asp:TextBox ID="txtAddress" runat="server" Height="129px" TextMode="MultiLine" Width="153px"></asp:TextBox>
</div>
</div>
<div class="formrow">
<div class="paymentfrmlabels">
City :</div>
<div class="paymentfrmtxtbox">
<asp:TextBox ID="txtCity" runat="server" Width="153px"></asp:TextBox>
</div>
</div>
<div class="formrow">
<div class="paymentfrmlabels">
Country :</div>
<div class="paymentfrmtxtbox">
<asp:DropDownList ID="drpCountry" Width="153px" runat="server">
</asp:DropDownList>
</div>
</div>
<div class="formrow">
<div class="paymentfrmlabels">
State :</div>
<div class="paymentfrmtxtbox">
<asp:TextBox ID="txtState" Width="153px" runat="server"></asp:TextBox>
</div>
</div>
<div class="formrow">
<div class="paymentfrmlabels">
Postal Code :</div>
<div class="paymentfrmtxtbox">
<asp:TextBox ID="txtPostalCode" Width="153px" runat="server"></asp:TextBox>
</div>
</div>
<div class="formrow" style="height: 90px; width: 670px;">
<div class="paymentfrmlabels">
Other Guest Names :</div>
<div class="paymentfrmtxtbox" style="margin-right:45px;">
<asp:TextBox ID="txtOtherGuest" runat="server" Height="90px" Width="153px" TextMode="MultiLine"></asp:TextBox>
</div>
<div class="paymentfrmlabels">
Other Information:</div>
<div class="paymentfrmtxtbox">
<asp:TextBox ID="txtOtherInf" runat="server" Height="90px" Width="153px" TextMode="MultiLine"></asp:TextBox>
</div>
</div>
<div class="formrow" style="vertical-align: text-top;">
<div class="paymentfrmlabels">
Identity Proof :</div>
</div>
<div class="formrow">
<div class="paymentfrmtxtbox">
</div>
</div>
<div class="formrow" style="text-align: right">
<div class="paymentfrmlabels">
<input id="txtLogoFileName1" type="file" style ="float :left; z-index:999;" name="txtSmallImage1FileName" runat="server" />
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers ="true" UpdateMode ="Conditional">
<ContentTemplate >
<div class="paymentfrmtxtbox">
<asp:Button ID="btnRemoveFilename1" runat="server" style="margin-left:50px; float :left; z-index:999;" Text="Remove" OnClick="btnRemoveFilename1_Click">
</asp:Button>
</div>
<asp:Label ID="lblLogoFileName1" runat="server" CssClass="labelText" ForeColor="Silver"> </asp:Label>
</div>
</ContentTemplate>
<Triggers >
<asp:PostBackTrigger ControlID ="btnRemoveFilename1" />
</Triggers>
</asp:UpdatePanel>
<div class="formrow" style="width: 300px;">
<div class="paymentfrmtxtbox ">
<asp:UpdatePanel ID="UpdatePanel3" UpdateMode ="Conditional" ChildrenAsTriggers ="true" runat="server">
<ContentTemplate >
Agency:
<asp:DropDownList ID="drpChannel" runat="server" Width="153px" AutoPostBack="True"
style=" float: right; height: 28px; margin-right: 65px;width: 157px;" >
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="drpChannel"
/>
<asp:AsyncPostBackTrigger ControlID="lnkNewChannel" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:LinkButton ID="lnkNewChannel" runat="server" style="display:block; float: right;margin-right: -71px; margin-top: 16px;" >New Channel</asp:LinkButton>
</div>
</div>
</div>
<div class="formrow" style="text-align: right; font-weight:bold; color:#000;">
</div>
<div class="formrow" style="text-align: right; width: 670px;">
<asp:LinkButton ID="lnkSubmit" CssClass="btn" runat="server" OnClick="lnkSubmit_Click1"
Width="65px" ValidationGroup="a">Check In</asp:LinkButton>
<asp:LinkButton ID="lnkCheckout" CssClass="btn" Width="65px" runat="server" OnClick="lnkCheckout_Click"
ValidationGroup="a">Check Out</asp:LinkButton>
<asp:LinkButton ID="lnkCancel" CssClass="btn" Width="65px" runat="server" OnClick="lnkCancel_Click1">Cancel</asp:LinkButton>
</div>
</div>
</div>
<ajaxtoolkit:ModalPopupExtender ID="ModalPopupExtender1" BackgroundCssClass="modalBackground" PopupControlID ="pnlChannel" TargetControlID ="lnkNewChannel" CancelControlID ="ImgBtnClose" runat="server">
</ajaxtoolkit:ModalPopupExtender>
<asp:Panel ID="pnlChannel" runat="server">
<div align="right" style ="padding-top :50px" >
<asp:ImageButton ID="ImgBtnClose" width="25px" Height ="25px" ImageUrl="~/Images/cross.png" runat="server" /></div>
<div style ="background-color:White ; border :20px; border-color:Blue;padding:20px 40px; border-radius:20px;" >
<style type="text/css">
.style1 {
width: 100%;
}
.style2
{
text-align: center;
font-weight: bold;
font-family: Andalus;
font-size: xx-large;
color: #434343;
}
.style3
{
width: 81px;
}
</style>
<div>
<table class="style1">
<tr>
<td class="style2" colspan="2">
Agency</td>
</tr>
<tr><td> </td><td> </td></tr>
<tr><td> </td><td> </td></tr>
<tr>
<td class="style3">
<asp:Label ID="lblName" runat="server" Text="Name:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtName" runat="server" Width="189px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="txtName" Display="Dynamic" ErrorMessage="Mandatory Field!!!"
ForeColor="Red" ValidationGroup="acssd23"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server"
ControlToValidate="txtName" Display="Dynamic"
ErrorMessage="Invalid Name Format!!!" Font-Names="Arial" Font-Size="8pt"
ForeColor="Red" SetFocusOnError="True"
ValidationExpression="^[a-zA-Z-'.\s]{1,50}" ValidationGroup="acssd23"></asp:RegularExpressionValidator>
</td>
</tr>
<tr><td> </td><td> </td></tr>
<tr>
<td class="style3">
<asp:Label ID="lblContact" runat="server" Text="Contact:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtContact" runat="server" Width="189px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"
ControlToValidate="txtContact" Display="Dynamic"
ErrorMessage="Mandatory Field!!!" ForeColor="Red"
ValidationGroup="acssd23"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtContact" Display="Dynamic"
ErrorMessage="Invalid Contact Format!!!" ForeColor="Red"
style="font-size: xx-small" ValidationExpression="^[0-9-+]*$"
ValidationGroup="acssd23"></asp:RegularExpressionValidator>
</td>
</tr>
<tr><td> </td><td> </td></tr>
<tr>
<td class="style3">
<asp:Label ID="lblAddress" runat="server" Text="Address:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtAddresss" runat="server" Height="64px" TextMode="MultiLine"
width="189px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server"
ControlToValidate="txtAddresss" Display="Dynamic"
ErrorMessage="Mandatory Field!!!" ForeColor="Red"
ValidationGroup="acssd23"></asp:RequiredFieldValidator>
</td>
</tr>
<tr><td> </td><td> </td></tr>
<tr>
<td class="style3">
<asp:Label ID="lblEmail" runat="server" Text="Email:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtEmails" runat="server" Width="189px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server"
ControlToValidate="txtEmails" Display="Dynamic"
ErrorMessage="Mandatory Field!!!" ForeColor="Red"
ValidationGroup="acssd23"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator015" runat="server"
ControlToValidate="txtEmail" ErrorMessage="Invalid Email Format!!!"
ForeColor="Red"
ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*"
ValidationGroup="acssd23"></asp:RegularExpressionValidator>
</td>
</tr>
<tr><td> </td><td> </td></tr>
<tr>
<td class="style3">
<asp:Label ID="lblWebsite" runat="server" Text="Website:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtWebsite" runat="server" Width="189px"></asp:TextBox>
</td>
</tr>
<tr><td> </td><td> </td></tr>
<tr>
<td class="style3">
</td>
<td>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td align ="right" >
<asp:Button ID="btnSubmit" CssClass="btn" Width ="140px" runat="server" Text="Submit"
onclick="btnSubmit_Click" style="height: 26px" ValidationGroup="acssd23" />
</td>
</tr>
</table>
</div>
</div>
</asp:Panel>
</asp:Panel>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
<Triggers>
<asp:PostBackTrigger ControlID="Button1" />
</Triggers>
<ContentTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server"Text="Upload" OnClick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
The default ASP.NET FileUpload control will never work with an UpdatePanel. You need a special AsyncFileUpload control as defined in an AjaxControl Toolkit.
<ajaxToolkit:AsyncFileUpload OnClientUploadError="uploadError"
OnClientUploadComplete="uploadComplete" runat="server"
ID="AsyncFileUpload1" Width="400px" UploaderStyle="Modern"
UploadingBackColor="#CCFFFF" ThrobberID="myThrobber" />
or you can use UpdatePanel Triggers
<Triggers>
<asp:PostBackTrigger ControlID="YourControlID" />
</Triggers>
I spent all afternoon on this today, using any number of solutions I found on various forums, including this one, CodeProject.com, asp.net forums, and a whole slew of others. I tried setting Postback triggers and AsyncPostback triggers, and this late at night I can't remember what all else. None of them worked, including the one marked as the answer on this page. What I finally found was an obscure post from 2007 on the asp.net forum which, for some reason now will not load on my browser. At any rate, what finally worked for me was replacing the
<form id="form1" runat="server>
tag with this:
<form id="Form1" method="post" enctype="multipart/form-data" runat="server">
Worked beautifully.
In my case it was in the Site.Master file, but in the case of the posting on forums.asp.net, it worked in a default.aspx file.
Update: The forums.asp.net site was down, but it's back up now: UpdatePanel + FileUpload + PostBackTrigger doesn't seem to work.

place the insert part at above the table in listviews

actually i have below listview at my user control page:
and i want to replace the insert part to above the table as below:
and my listview code is as below:
<asp:ListView ID="lv_Uc_Module" runat="server"
onitemediting="lv_Uc_Module_ItemEditing"
onitemupdating="lv_Uc_Module_ItemUpdating"
onitemcanceling="lv_Uc_Module_ItemCanceling"
onitemdeleting="lv_Uc_Module_ItemDeleting"
OnItemDataBound="lv_Uc_Module_ItemDataBound"
InsertItemPosition="LastItem"
OnSorting="lv_Uc_Module_Sorting"
oniteminserting="lv_Uc_Module_ItemInserting"
DataKeyNames="EmpID">
<LayoutTemplate>
<table id="table_Lv_Layout" runat="server">
<tr id="tr_Table_Layout" runat="server">
<td id="td_Table_Layout" runat="server">
<table ID="itemPlaceholderContainer" runat="server" class="th_ItemTemplate">
<tr id="tr_Table_IphContainer" runat="server" style="">
<th id="th1_Table_IphContainer" runat="server">
<asp:Label ID="lb1_Table_IphContainer" runat="server" Text=""></asp:Label>
<asp:ImageButton ID="imb1_Table_IphContainer" CommandArgument="EmpID" CommandName="Sort" ImageUrl="~/Images/asc.png" runat="server" />
</th>
<th id="th2_Table_IphContainer" runat="server">
<asp:Label ID="lb2_Table_IphContainer" runat="server" Text=""></asp:Label>
<asp:ImageButton ID="imb2_Table_IphContainer" CommandArgument="EmpName" CommandName="Sort" ImageUrl="~/Images/asc.png" runat="server" />
</th>
<th id="th3_Table_IphContainer" runat="server">
<asp:Label ID="lb3_Table_IphContainer" runat="server" Text=""></asp:Label>
</th>
<th id="th4_Table_IphContainer" runat="server">
<asp:Label ID="lb4_Table_IphContainer" runat="server" Text=""></asp:Label>
</th>
<th id="th5_Table_IphContainer" runat="server">
<asp:Label ID="lb5_Table_IphContainer" runat="server" Text=""></asp:Label>
</th>
<th id="th6_Table_IphContainer" runat="server">
</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="tr_Validate_Table_Layout" runat="server">
<td id="td_Validate_Table_Layout" runat="server" style="text-align: center;background-color: #CCCCCC;">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="You received the following errors:" ShowMessageBox="true" ShowSummary="false" ValidationGroup="VGEditTmp" />
<asp:ValidationSummary ID="ValidationSummary2" runat="server" HeaderText="You received the following errors:" ShowMessageBox="true" ShowSummary="false" ValidationGroup="VGInsertTmp" />
</td>
</tr>
</table>
<br />
<asp:DataPager ID="lv_DataPager" runat="server" PagedControlID="lv_Uc_Module" PageSize="5" OnPreRender="lv_DataPager_PreRender">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="true" ShowLastPageButton="true" />
<asp:TemplatePagerField>
<PagerTemplate>
<span style="color:Maroon;">Records:
<%# Container.StartRowIndex >= 0 ? (Container.StartRowIndex + 1) : 0 %>
-
<%# (Container.StartRowIndex + Container.PageSize) > Container.TotalRowCount ? Container.TotalRowCount : (Container.StartRowIndex + Container.PageSize)%>
of
<%# Container.TotalRowCount %>
<span style="color:Red;">
OR
</span>
<span style="color: Blue;">
Page
<%# Container.TotalRowCount>0 ? (Container.StartRowIndex / Container.PageSize) + 1 : 0 %>
of
<%# Math.Ceiling((double)Container.TotalRowCount / Container.PageSize) %>
</span>
</span>
</PagerTemplate>
</asp:TemplatePagerField>
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr class="tr_ItemTemplate">
<td>
<asp:Label ID="lb_ItemTemp1" runat="server" Text='' />
</td>
<td>
<asp:Label ID="lb_ItemTemp2" runat="server" Text='' />
</td>
<td>
<asp:Label ID="lb_ItemTemp3" runat="server" Text='' />
</td>
<td>
<asp:Label ID="lb_ItemTemp4" runat="server" Text='' />
</td>
<td>
<asp:Label ID="lb_ItemTemp5" runat="server" Text='' />
</td>
<td>
<asp:Button ID="btn_Edit" runat="server" CommandName="Edit" Text="" CssClass="btn_Edit" CausesValidation="True" />
<asp:Button ID="btn_Delete" runat="server" CommandName="Delete" Text="" CssClass="btn_Delete" CausesValidation="false" OnClientClick="return confirm('Are you sure you want to delete this item?');" />
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr style="background-color:#008A8C;color: #FFFFFF;">
<td>
<asp:Label ID="lb_ItemTemp1" runat="server" Text='' />
</td>
<td>
<asp:TextBox ID="td_EditTemp1" runat="server" Text='' ValidationGroup="VGEditTmp" />
<asp:RequiredFieldValidator runat="server" ID="RequiredName" ControlToValidate="td_EditTemp1" ErrorMessage="Name is required" ValidationGroup="VGEditTmp" Display="None" ></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="regName" runat="server" ControlToValidate="td_EditTemp1" ValidationExpression="^[a-zA-Z'.\s]{1,50}" ErrorMessage="Enter a valid Name" ValidationGroup="VGEditTmp" Display="None"></asp:RegularExpressionValidator>
</td>
<td>
<asp:TextBox ID="td_EditTemp2" runat="server" Text='' />
</td>
<td>
<asp:TextBox ID="td_EditTemp3" runat="server" Text='' ValidationGroup="VGEditTmp" />
<asp:RangeValidator ID="ValidateAge" runat="server" ControlToValidate="td_EditTemp3" MinimumValue="18" MaximumValue="50" Type="Integer" ErrorMessage="Age should be within the valid interval(18-50)!" ValidationGroup="VGEditTmp" SetFocusOnError="true" Display="None"></asp:RangeValidator>
</td>
<td>
<asp:TextBox ID="td_EditTemp4" runat="server" Text='' />
</td>
<td>
<asp:Button ID="btn_Update" runat="server" CommandName="Update" Text="Update" ValidationGroup="VGEditTmp" />
<asp:Button ID="btn_Cancel" runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
</td>
</tr>
</EditItemTemplate>
<InsertItemTemplate>
<tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
<td>
</td>
<td>
<asp:TextBox ID="td_EditTemp1" runat="server" Text='' ValidationGroup="VGInsertTmp" />
<asp:RequiredFieldValidator runat="server" ID="RequiredName" ControlToValidate="td_EditTemp1" ErrorMessage="Name is required" ValidationGroup="VGInsertTmp" Display="None"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="regName" runat="server" ControlToValidate="td_EditTemp1" ValidationExpression="^[a-zA-Z'.\s]{1,50}" ErrorMessage="Enter a valid Name" ValidationGroup="VGInsertTmp" Display="None"></asp:RegularExpressionValidator>
</td>
<td>
<asp:TextBox ID="td_EditTemp2" runat="server" Text='' />
</td>
<td>
<asp:TextBox ID="td_EditTemp3" runat="server" Text='' ValidationGroup="VGInsertTmp" />
<asp:RangeValidator ID="ValidateAge" runat="server" ControlToValidate="td_EditTemp3" MinimumValue="18" MaximumValue="50" Type="Integer" ErrorMessage="Age should be within the valid interval(18-50)!" ValidationGroup="VGInsertTmp" SetFocusOnError="true" Display="None"></asp:RangeValidator>
</td>
<td>
<asp:TextBox ID="td_EditTemp4" runat="server" Text='' />
</td>
<td>
<asp:Button ID="btn_Insert" runat="server" CommandName="Insert" Text="Insert" ValidationGroup="VGInsertTmp" />
<asp:Button ID="btn_Cancel" runat="server" CommandName="Cancel" Text="Clear" CausesValidation="false" />
</td>
</tr>
</InsertItemTemplate>
</asp:ListView>
could you please guide me how to overcome this problem. i'm using asp.net and c#.
Appreciate your consideration.
I think you need to change your GridView's InsertItemPosition property from InsertItemPosition="LastItem"
to
InsertItemPosition="FirstItem"
in your declaration.

Ajax TabPanels trigger validation for other tabs in ASP.Net 4.0

I have Ajax TabPanel with Tab "Employee List" "Add Employee" "Edit Employee"
On Employee List Tab i use gridview to display list of employee along with link Button to view details of employee on same tab and "Del" button to delete employee. It worked fine but when i added Controls to Second tab "Add Employee" along with validation controls. After this gridview in Tab one is not working as it trigger validation on second Tab.
How can i stop this validation which is triggered by controls on Tab 1
Below is the code
<asp:TabContainer ID="TabContainer1" runat="server" Height="320px" Width="100%"
ActiveTabIndex="0" >
<asp:TabPanel ID="atpEmployeeList" runat="server" >
<HeaderTemplate>Employee List</HeaderTemplate>
<ContentTemplate>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="style1" align="left" valign="top">
<b>Employee List</b>
<asp:GridView ID="gvEmployeeList" runat="server" AutoGenerateColumns="False"
DataKeyNames="eCode" BackColor="White" BorderColor="#336666"
BorderStyle="None" BorderWidth="2px" CellPadding="4"
GridLines="Horizontal" onrowcommand="gvEmployeeList_RowCommand"
onrowdatabound="gvEmployeeList_RowDataBound" >
<Columns>
<asp:BoundField DataField="eSno" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="eSno" />
<asp:BoundField DataField="eFirstName" HeaderText="First Name"
SortExpression="eFirstName" />
<asp:BoundField DataField="eLastName" HeaderText="Last Name"
SortExpression="eLastName" />
<asp:BoundField DataField="eDepartment" HeaderText="Department"
SortExpression="eDepartment" />
<asp:BoundField DataField="eSalary" HeaderText="Salary"
SortExpression="eSalary" />
<asp:TemplateField HeaderText="Details">
<ItemTemplate>
<asp:LinkButton ID="lnkBtnEmpDetails" CommandArgument='<%# Eval("eSno") %>' CommandName="ViewDetails" runat="server">
View</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="lnkBtnEmpDelete" CommandArgument='<%# Eval("eSno") %>' CommandName="Delete" runat="server">
Del</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="White" ForeColor="#333333" />
<HeaderStyle BackColor="#336699" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#336699" ForeColor="White" HorizontalAlign="Right" />
<RowStyle BackColor="White" ForeColor="#333333" />
<SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F7F7F7" />
<SortedAscendingHeaderStyle BackColor="#487575" />
<SortedDescendingCellStyle BackColor="#E5E5E5" />
<SortedDescendingHeaderStyle BackColor="#275353" />
</asp:GridView>
</td>
<td width="250px" align="left" valign="top">
<b>Employee Details</b>
<br />
<table width="280px" align="left" cellpadding="3" cellspacing="0" >
<tr>
<td class="style8" bgcolor="#336699">
Code</td>
<td>
<asp:Label ID="lblEmpCode" runat="server" ></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
Fisrt Name</td>
<td>
<asp:Label ID="lblFirstName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style5" bgcolor="#336699">
Last Name</td>
<td class="style6">
<asp:Label ID="lblLastName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
Designation</td>
<td>
<asp:Label ID="lblDesignation" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
Department</td>
<td>
<asp:Label ID="lblDepartment" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
Salary</td>
<td>
<asp:Label ID="lblSalary" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
Join Date</td>
<td>
<asp:Label ID="lblJoinDate" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
Phone</td>
<td>
<asp:Label ID="lblPhone" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
Address</td>
<td>
<asp:Label ID="lblAddress" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
City</td>
<td>
<asp:Label ID="lblCity" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style4">
</td>
<td>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="atpAddEmployee" runat="server" >
<HeaderTemplate>Add Employee</HeaderTemplate>
<ContentTemplate>
<div><b>Enter Details of New Employee</b></div>
<table border="0px"><tr>
<td width="400px">
<div class="spacer"></div>
<div class="row">
<asp:Label ID="lblAEmpCode" CssClass="txtLabel" runat="server" Text="Code :"></asp:Label>
<asp:TextBox ID="txtACode" runat="server" CssClass="txt4Digit"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvCode" runat="server" ErrorMessage="*"
ControlToValidate="txtACode"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblAFN" CssClass="txtLabel" runat="server" Text="First Name :"></asp:Label>
<asp:TextBox ID="txtAFN" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
ControlToValidate="txtAFN"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblALN" CssClass="txtLabel" runat="server" Text="Last Name :"></asp:Label>
<asp:TextBox ID="txtALN" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
ControlToValidate="txtALN"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblADesignation" CssClass="txtLabel" runat="server" Text="Designation :"></asp:Label>
<asp:TextBox ID="txtADesignation" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="*"
ControlToValidate="txtADesignation"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblADepartment" CssClass="txtLabel" runat="server" Text="Department :"></asp:Label>
<asp:TextBox ID="txtADepartment" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="*"
ControlToValidate="txtADepartment"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblASalary" CssClass="txtLabel" runat="server" Text="Salary :"></asp:Label>
<asp:TextBox ID="txtASalary" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="*"
ControlToValidate="txtASalary"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblAJoinDate" CssClass="txtLabel" runat="server" Text="Join Date :"></asp:Label>
<asp:TextBox ID="txtAJoinDate" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="*"
ControlToValidate="txtAJoinDate"></asp:RequiredFieldValidator>
</div>
</td>
<td width="400px">
<div class="spacer"></div>
<div class="row">
<asp:Label ID="lblAAddress" CssClass="txtLabel" runat="server" Text="Address :"></asp:Label>
<asp:TextBox ID="txtAAddress" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="*"
ControlToValidate="txtAAddress"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblACity" CssClass="txtLabel" runat="server" Text="City :"></asp:Label>
<asp:TextBox ID="txtACity" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ErrorMessage="*"
ControlToValidate="txtACity"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblACountry" CssClass="txtLabel" runat="server" Text="Country :"></asp:Label>
<asp:UpdatePanel ID="updatepanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddCountry" runat="server" CssClass="ddGeneral" DataTextField="Country"
DataValueField="CountryId" OnSelectedIndexChanged="ddCountry_SelectedIndexChanged"
AutoPostBack="true" AppendDataBoundItems="true" >
<asp:ListItem Value="0">Select Country</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="row">
<asp:Label ID="lblAState" CssClass="txtLabel" runat="server" Text="State :"></asp:Label>
<asp:UpdatePanel ID="updatePnlState" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddState" runat="server" CssClass="ddGeneral" DataTextField="Region" DataValueField="RegionId" AppendDataBoundItems="true">
<asp:ListItem Value="0">Select State</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="updProgLoading" runat="server" >
<ProgressTemplate>
<img src="images/ajax-loader-small.gif" align="left" alt="Loading..." vspace="0" />
</ProgressTemplate>
</asp:UpdateProgress>
</div>
<div class="row">
<asp:Label ID="lblALL" CssClass="txtLabel" runat="server" Text="Landline :"></asp:Label>
<asp:TextBox ID="txtALL" runat="server" CssClass="txtbox"></asp:TextBox>
</div>
<div class="row">
<asp:Label ID="lblAMobile" CssClass="txtLabel" runat="server" Text="Mobile :"></asp:Label>
<asp:TextBox ID="txtAMobile" runat="server" CssClass="txtbox"></asp:TextBox>
</div>
<div class="row">
<asp:Label ID="lblAEmail" CssClass="txtLabel" runat="server" Text="Email :"></asp:Label>
<asp:TextBox ID="txtAEmail" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ErrorMessage="*"
ControlToValidate="txtAEmail"></asp:RequiredFieldValidator>
</div>
</td>
</tr>
<tr><td colspan="2" align="center" height="40px">
<asp:Button ID="btnAddEmployee" runat="server" Text="Add Employee"
CssClass="btn" onclick="btnAddEmployee_Click" /> <input id="Reset1" type="reset" class="btn" value="Reset" />
</td></tr>
</table>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="atpEditEmployee" runat="server" >
<HeaderTemplate>Edit Employee</HeaderTemplate>
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<input id="Button2" type="button" value="Next" onclick="MoveTab(1)" />
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
You should look at utilising the ValidationGroup attribute for validators. For example for all the validators in the atpAddEmployee tab you would set the attribute like so ValidationGroup="atpAddEmployee" or any other name that you think appropriate.
I've taken one of the validators from the atpAddEmployee tab and added the attribute as described above.
<asp:RequiredFieldValidator ID="rfvCode" runat="server" ErrorMessage="*" ControlToValidate="txtACode" ValidationGroup="atpAddEmployee"></asp:RequiredFieldValidator>
For that particular tab you would also need to add the ValidationGroup attribute to the button that should trigger the validation, see below.
<asp:Button ID="btnAddEmployee" runat="server" Text="Add Employee" CssClass="btn" onclick="btnAddEmployee_Click" ValidationGroup="atpAddEmployee" />
Some further reading, MSDN and W3Schools.

Categories

Resources