I have a calender selector that looks like
<asp:ImageButton ID="calStartImage" runat="server" ImageUrl="../images/SmallCalendar.gif"
AlternateText="Please select start date" />
<ajaxToolkit:CalendarExtender ID="calStartDate" runat="server" TargetControlID="txtStartDate"
Format="MM/dd/yyyy" PopupButtonID="calStartImage" />
And A search button that look like this
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"
CausesValidation="false" />
When I select a date from the calender and press Search..The first time btnSearch_Click doesnt fire..If I click Search again it works fine. So I have to click the Search button twice before the click event works. This only happens if I select a date from the calender control.
Here is the full control:
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajaxToolkit:ToolkitScriptManager>
<table>
<tr>
<td class="SearchBox">
<table>
<tr>
<td colspan="2">
<b>Enter name to filter results</b>
<asp:TextBox ID="txtProjectName" runat="server"></asp:TextBox><br />
<br />
</td>
</tr>
<tr>
<td valign="middle">
<b>From:</b>
<asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>
<asp:ImageButton ID="calStartImage" runat="server" ImageUrl="../images/SmallCalendar.gif"
AlternateText="Please select start date" />
<ajaxToolkit:CalendarExtender ID="calStartDate" runat="server" TargetControlID="txtStartDate"
Format="MM/dd/yyyy" PopupButtonID="calStartImage" />
<b>Thru:</b>
<asp:TextBox ID="txtEndDate" runat="server"></asp:TextBox>
<asp:ImageButton runat="server" ID="calEndImage" ImageUrl="../images/SmallCalendar.gif"
AlternateText="Please select end date" />
<ajaxToolkit:CalendarExtender ID="calEndDate" runat="server" TargetControlID="txtEndDate"
Format="MM/dd/yyyy" PopupButtonID="calEndImage" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="From Date is Required"
ControlToValidate="txtStartDate" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Thru Date is Required"
ControlToValidate="txtEndDate" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Invalid From Date"
ControlToValidate="txtStartDate" Display="Dynamic" MaximumValue="1/1/2099" MinimumValue="1/1/2006"
SetFocusOnError="True" Type="Date"></asp:RangeValidator>
<asp:RangeValidator ID="RangeValidator2" runat="server" ControlToValidate="txtEndDate"
ErrorMessage="Invalid Thru Date" SetFocusOnError="True" Type="Date" Display="Dynamic"
MaximumValue="1/1/2999" MinimumValue="1/1/2006"></asp:RangeValidator>
<br />
</td>
</tr>
<tr>
<td align="left">
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"
CausesValidation="false" />
</td>
</tr>
</table>
</td>
<td align="right" style="width:560px">
Guide
</td>
</tr>
</table>
Here is more from the page....
<ajaxToolkit:ModalPopupExtender ID="mdlPopupExtender" runat="server" TargetControlID="btnShowPopup"
PopupControlID="pnlProject" BackgroundCssClass="modalBackground" Drag="true"
DropShadow="true" CancelControlID="btnClose" PopupDragHandleControlID="TitleBar">
</ajaxToolkit:ModalPopupExtender>
<asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
<asp:Panel ID="pnlProject" runat="server" BackColor="WhiteSmoke">
<asp:Panel ID="TitleBar" runat="server" CssClass="modalPopupTitleBar">
Add/Edit Project
</asp:Panel>
<asp:UpdatePanel ID="upPopList" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAddNew" EventName="Click" />
</Triggers>
<ContentTemplate>
<table cellspacing="10">
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<b>Project Name:</b>
</td>
<td>
<asp:TextBox ID="txtProject" runat="server" Width="200px"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqProject" runat="server" ErrorMessage="Required!"
Display="Dynamic" ControlToValidate="txtProject"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<b>Field Office:</b>
</td>
<td>
<asp:TextBox ID="txtFieldOffice" runat="server" Width="200px"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqFieldOffice" runat="server" ErrorMessage="Required!"
Display="Dynamic" ControlToValidate="txtFieldOffice"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<b>Created By:</b>
</td>
<td>
<asp:Label ID="lblCreatedBy" runat="server"></asp:Label>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<table>
<tr>
<td>
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Save" OnClick="btnSubmit_Click" />
<asp:Button ID="btnClose" runat="server" Text="Close" CausesValidation="false" />
<br />
</td>
</tr>
</table>
</asp:Panel>
Any Ideas?
You need to add ValidationGroup to your validation controls so that each validation group can perform validation independently from other validation group on a specific page. more you can read here Specifying Validation Groups
Here is your code with group validation. you can change it as your environment.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<table>
<tr>
<td>
<table>
<tr>
<td colspan="2">
<b>Enter name to filter results</b>
<asp:TextBox ID="txtProjectName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td valign="middle">
<b>From:</b>
<asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="formDateRequiredValidator" ValidationGroup="Date"
runat="server" ErrorMessage="Enter From Date." ControlToValidate="txtStartDate"></asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidator1" runat="server" ValidationGroup="Date" ErrorMessage="Invalid From Date"
ControlToValidate="txtStartDate" Display="Dynamic" MaximumValue="1/1/2099" MinimumValue="1/1/2006"
SetFocusOnError="True" Type="Date"></asp:RangeValidator>
<asp:ImageButton ID="calStartImage" runat="server" AlternateText="Please select start date" />
<asp:CalendarExtender ID="calStartDate" runat="server" TargetControlID="txtStartDate"
Format="MM/dd/yyyy" PopupButtonID="calStartImage" />
<b>Thru:</b>
<asp:TextBox ID="txtEndDate" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="endDateRequiredValidator" ValidationGroup="Date"
runat="server" ErrorMessage="Enter Thru Date." ControlToValidate="txtEndDate"></asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidator2" ValidationGroup="Date" runat="server" ErrorMessage="Invalid From Date"
ControlToValidate="txtStartDate" Display="Dynamic" MaximumValue="1/1/2099" MinimumValue="1/1/2006"
SetFocusOnError="True" Type="Date"></asp:RangeValidator> 
<asp:ImageButton runat="server" ID="calEndImage" ImageUrl="../images/SmallCalendar.gif"
AlternateText="Please select end date" />
<asp:CalendarExtender ID="calEndDate" runat="server" TargetControlID="txtEndDate"
Format="MM/dd/yyyy" PopupButtonID="calEndImage" />
</td>
</tr>
<tr>
<td align="left">
<asp:Button ID="btnSearch" runat="server" Text="Search" ValidationGroup="Date" CausesValidation="false" />
</td>
</tr>
</table>
</td>
<td align="right">
Guide
</td>
</tr>
</table>
<asp:ModalPopupExtender ID="mdlPopupExtender" runat="server" TargetControlID="btnShowPopup"
PopupControlID="pnlProject" BackgroundCssClass="modalBackground" Drag="true"
DropShadow="true" CancelControlID="btnClose" PopupDragHandleControlID="TitleBar">
</asp:ModalPopupExtender>
<asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
<asp:Panel ID="pnlProject" runat="server" BackColor="WhiteSmoke">
<asp:Panel ID="TitleBar" runat="server">
Add/Edit Project
<%-- I have added this Button you can replace with yours becaus specified in Triggers to run the code i need to add this(btnAddNew) Button--%>
<asp:Button ID="btnAddNew" runat="server" Text="AddNew" />
</asp:Panel>
<asp:UpdatePanel ID="upPopList" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAddNew" />
</Triggers>
<ContentTemplate>
<table>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<b>Project Name:</b>
</td>
<td>
<asp:TextBox ID="txtProject" runat="server" Width="200px"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqProject" ValidationGroup="ProjectInfo" runat="server"
ErrorMessage="Required!" Display="Dynamic" ControlToValidate="txtProject"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<b>Field Office:</b>
</td>
<td>
<asp:TextBox ID="txtFieldOffice" runat="server" Width="200px"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqFieldOffice" ValidationGroup="ProjectInfo" runat="server"
ErrorMessage="Required!" Display="Dynamic" ControlToValidate="txtFieldOffice"></asp:RequiredFieldValidator>
</td>
</tr>
</td> </tr>
<tr>
<td>
<b>Created By:</b>
</td>
<td>
<asp:Label ID="lblCreatedBy" runat="server"></asp:Label>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<table>
<tr>
<td>
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Save" OnClick="btnSubmit_Click" />
<asp:Button ID="btnClose" runat="server" Text="Close" CausesValidation="false" ValidationGroup="ProjectInfo"
OnClick="btnClose_Click" />
<br />
</td>
</tr>
</table>
</asp:Panel>
Hope this helps.
I don't know why but your problem can be solved by setting the CausesValidation property of btnSearch to true
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"
CausesValidation="true" />
Related
I have a RequiredFieldValidator for dropdownlist. Both are inside UpdatePanel. It is not validating user selection from dropdownlist when submit button is clicked. Please guide what am I missing.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div id="divFilter">
<asp:UpdatePanel ID="uplMain" runat="server">
<ContentTemplate>
<asp:PlaceHolder ID="PlaceHolder1" runat="server">
<table>
<tr>
<td valign="top">
<table>
<tr>
<td>
<asp:CheckBox ID="chkBusiness" runat="server" Text="Business Division" CssClass="chkbox" />
</td>
<td>
<asp:DropDownList ID="ddlBusiness" runat="server" AppendDataBoundItems="true" AutoPostBack="true"
CausesValidation="True" OnSelectedIndexChanged="ddlBusiness_SelectedIndexChanged"
ValidationGroup="grpSubmit" Width="350px">
<asp:ListItem Selected="True" Value="-1">--- SELECT ---</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvBusiness" runat="server" ControlToValidate="ddlBusiness"
ToolTip="Please select a Business." ErrorMessage="*" CssClass="required" Display="Dynamic"
ValidationGroup="grpSubmit" Enabled="false">
</asp:RequiredFieldValidator>
</td>
</tr>
</table>
</td>
</tr>
</table>
</asp:PlaceHolder>
<hr size="1" />
<div style="text-align: center">
<table style="width: 10%">
<tr>
<td>
<asp:Button ID="btnHome" runat="server" Text="Home" OnClick="btnHome_Click" CssClass="btn" />
</td>
<td>
<asp:Button ID="btnSubmitReport" runat="server" Text="Submit" OnClick="btnSubmitReport_Click"
ValidationGroup="grpSubmit" CssClass="btn" />
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
Try setting the Enabled attribute in the RequiredFieldValidator element to "True".
error creating control , Unable to create type 'cc1: TabContainer', could not load file or assembly System.Web.extension, Version=1.0.61025.0'
The system cannot find the file specified
im getting this error . can u tell me where im wrong? why cant i see my design in aspx ?
code
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<cc1:TabContainer runat="server" ID="Tab_Continer" ActiveTabIndex="0">
<cc1:TabPanel ID="TabPnl_Project" runat="server">
<HeaderTemplate>
Keyword Position</HeaderTemplate>
<ContentTemplate>
<table>
<tr>
<td>
<asp:Label ID="lbl_Project" runat="server" Text="Project"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlProject" runat="server" OnSelectedIndexChanged="ddlProject_SelectedIndexChanged"
AutoPostBack="true">
</asp:DropDownList>
<asp:RequiredFieldValidator Display="Dynamic" ID="RequiredFieldValidator3" runat="server"
ErrorMessage="*" ControlToValidate="ddlProject" ValidationGroup="ValPos"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblLkeyword" runat="server" Text="Keyword"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlKeyword" runat="server" OnSelectedIndexChanged="ddlKeyword_SelectedIndexChanged"
AutoPostBack="true">
</asp:DropDownList>
<asp:RequiredFieldValidator Display="Dynamic" ID="RequiredFieldValidator2" runat="server"
ErrorMessage="*" ControlToValidate="ddlKeyword" ValidationGroup="ValPos"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblPos" runat="server" Text="Position"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtPostion" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator Display="Dynamic" ID="RequiredFieldValidator1" runat="server"
ErrorMessage="*" ControlToValidate="txtPostion" ValidationGroup="ValPos"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtPostion"
ValidationExpression="^[0-9]{0,3}$" ErrorMessage="*" ValidationGroup="ValPos"
ToolTip="Enter only numeric values" Display="Dynamic"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl_Date" runat="server" Text="Date"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="Ajax_Calend" runat="server" TargetControlID="txtDate">
</cc1:CalendarExtender>
<asp:RequiredFieldValidator Display="Dynamic" ID="Valid_Req_DtFrm" runat="server"
ErrorMessage="*" ControlToValidate="txtDate" ValidationGroup="ValPos"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
</td>
<td align="left">
<asp:Button ID="btn_Submit" runat="server" Text="Submit" ValidationGroup="ValPos"
OnClick="btn_Submit_Click" CssClass="button" />
</td>
</tr>
<tr>
<td>
</td>
<td align="left">
<asp:Label ID="LblMsg" runat="server" Font-Bold="true"></asp:Label>
</td>
</tr>
</table>
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="Tab_Update" runat="server">
<HeaderTemplate>
Traffic</HeaderTemplate>
<ContentTemplate>
<asp:UpdatePanel ID="update12" runat="server">
<ContentTemplate>
<table>
<tr>
<td>
<asp:Label ID="lblProject" runat="server" Text="Project"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddl_Project" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator Display="Dynamic" ID="RequiredFieldValidator4" runat="server"
ErrorMessage="*" ControlToValidate="ddl_Project" ValidationGroup="ValTraffic"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblTraffic" runat="server" Text="Traffic"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtTarffic" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator Display="Dynamic" ID="RequiredFieldValidator5" runat="server"
ErrorMessage="*" ControlToValidate="txtTarffic" ValidationGroup="ValTraffic"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtTarffic"
ValidationExpression="^[0-9]{0,5}$" ErrorMessage="*" ToolTip="Enter only numeric values"
ValidationGroup="ValTraffic" Display="Dynamic"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Date"></asp:Label>
</td>
<td>
<asp:TextBox ID="Txt_Date" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="Txt_Date">
</cc1:CalendarExtender>
<asp:RequiredFieldValidator Display="Dynamic" ID="RequiredFieldValidator6" runat="server"
ErrorMessage="*" ControlToValidate="Txt_Date" ValidationGroup="ValTraffic"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
</td>
<td align="left">
<asp:Button ID="btnSave" runat="server" ValidationGroup="ValTraffic" Text="Submit"
OnClick="btnSave_Click" CssClass="button" />
</td>
</tr>
<tr>
<td>
</td>
<td align="left">
<asp:Label ID="lbl_Msg" runat="server" Font-Bold="true"></asp:Label>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
Posted is an abridged code of my user control. I have added an update panel over radio button and want to execute a server function which will toggle between consultant drop down list and reference name text box based on the selection without a full post back. But the radio button is causing a full postback. What am I doing wrong here?
<aj:ModalPopupExtender ID="ModalPopup1" runat="server" PopupControlID="Panel1"
BackgroundCssClass="PopupBackground" CancelControlID="closeButton">
</aj:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server" CssClass="PopupPanel" align="center" style = "display:none">
<h1 class="PopupHeading">Add New Candidate</h1>
<table class="PopupTable">
<tr>
<td>
<asp:Label ID="firstNameLabel" runat="server" Text="First Name" CssClass="PopupLabel"></asp:Label>
</td>
<td>
<asp:TextBox ID="firstNameTextBox" runat="server" Font-Size="14px" ></asp:TextBox>
</td>
<td class="ValidationError">
<asp:RequiredFieldValidator ID="nameRequiredFieldValidator" runat="server"
ValidationGroup="AddCandidateValidationGroup"
ErrorMessage="Name is required" Text="*"
ControlToValidate="firstNameTextBox" CssClass="failureNotification">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="emailLabel" runat="server" Text="Email" CssClass="PopupLabel"></asp:Label>
</td>
<td>
<asp:TextBox ID="emailTextBox" runat="server" Font-Size="14px" ></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ValidationGroup="AddCandidateValidationGroup"
ErrorMessage="Email is required" Text="*"
ControlToValidate="emailTextBox" CssClass="failureNotification">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:RegularExpressionValidator ID="emailRegularExpressionValidator"
runat="server" ErrorMessage="Incorrect Email"
ValidationGroup="AddCandidateValidationGroup"
ControlToValidate="emailTextBox"
ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*"
CssClass="failureNotification" Text="Incorrect email">
</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="referredByLabel" runat="server" Text="Referred By" CssClass="PopupLabel"></asp:Label>
</td>
<td>
<asp:UpdatePanel ID="updatepanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:RadioButtonList ID="RefConsRadButList" runat="server" AutoPostBack="true"
RepeatDirection="Horizontal" OnSelectedIndexChanged="RefConsRadButList_SelectedIndexChanged" CausesValidation="false">
<asp:ListItem >Consultant</asp:ListItem>
<asp:ListItem>Referral</asp:ListItem>
<asp:ListItem Selected="True">N/A</asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="RefConsRadButList" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td>
<asp:Label ID="consultantNameLabel" runat="server" Text="Consultant Name" Visible="false" CssClass="PopupLabel"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ConsultantDrDoList" runat="server" Visible="false">
<asp:ListItem>Select Consultant</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="referenceNameLabel" runat="server" Text="Reference Name" Visible = "false" CssClass="PopupLabel"></asp:Label>
</td>
<td>
<asp:TextBox ID="ReferralNameTextBox" runat="server" Visible="false"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="refNameRequiredFieldValidator" runat="server"
ValidationGroup="AddCandidateValidationGroup"
ErrorMessage="Referral name is required" Text="*"
ControlToValidate="phoneTextBox" CssClass="failureNotification">*</asp:RequiredFieldValidator>
</td>
</tr>
</table>
<br />
<asp:Button ID="addButton" runat="server" Text="Add" onclick="addButton_Click" ValidationGroup="AddCandidateValidationGroup"/>
<asp:Button ID="closeButton" runat="server" Text="Close" />
<div id="AddStatus">
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
ValidationGroup="AddCandidateValidationGroup"
HeaderText="Add user failed due to the following errors:" CssClass="PopupValidationError"/>
</div>
</asp:Panel>
instead of using updatepanel on modalpopup panel you can try something from code behind to serve the purpose.
<asp:scriptmanager id="ScriptManager1" runat="server">
</asp:scriptmanager>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="modalBackground"
CancelControlID="btnCancel" PopupControlID="Panel1"
TargetControlID="HiddenField1">
</asp:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server" CssClass="Panel">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" Height="34px" RepeatDirection="Horizontal"
Width="129px" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
AutoPostBack="True">
<asp:ListItem>Option1</asp:ListItem>
<asp:ListItem>Option2</asp:ListItem>
</asp:RadioButtonList>
<asp:TextBox ID="txt1" runat="server"
Visible="False"></asp:TextBox>
<asp:TextBox ID="txt2" runat="server"
Visible="False"></asp:TextBox>
</asp:Panel>
===========================================
Code Behind:
===========================================
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (RadioButtonList1.SelectedIndex == 0)
{
txt1.Visible = true;
ModalPopupExtender1.Show();
}
else
{
txt2.Visible = true;
ModalPopupExtender1.Show();
}
}
We have problem with custom lightbox in dhtmlxScheduler because in your example you used the HTML controller. can we use server side controller in our custom lightbox By the way did you place custome form in side User Controller
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="uc_taskFrom.ascx.cs" Inherits="Compudata_ProjectManager.userController.uc_taskFrom" %>
<div>
<!-- begin of Content Create TaskForm -->
<!-- Script manager-->
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<!-- Validation Summary msg vs_TaskForm-->
<asp:ValidationSummary ID="vs_TaskForm" runat="server" ForeColor="#CC0000" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<!-- begin of Content Create TaskForm -->
<asp:Panel ID="Panel1" runat="server" GroupingText="Create New Task">
<table>
<tr>
<td>
<label>
Project:</label>
</td>
<td>
<asp:DropDownList ID="ddl_projectsList" runat="server" DataSourceID="SqlDataSourceProjectList"
DataTextField="projectName" DataValueField="projectID" AppendDataBoundItems="True"
OnSelectedIndexChanged="ddl_projectsList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Value="-1">Select Project</asp:ListItem>
</asp:DropDownList>
<asp:CompareValidator ID="cv_projectList" runat="server" ControlToValidate="ddl_projectsList"
ErrorMessage="Select Project" ForeColor="#FC0000" Operator="NotEqual" ValueToCompare="-1">*</asp:CompareValidator>
<asp:SqlDataSource ID="SqlDataSourceProjectList" runat="server" ConnectionString="<%$ ConnectionStrings:Compudata_ProjectManagerConnection %>"
SelectCommand="SELECT [projectID], [projectName] FROM [Projects] ORDER BY [projectName]">
</asp:SqlDataSource>
</td>
</tr>
<tr>
<td>
<label>
Task Name:</label><em>*</em>
</td>
<td>
<asp:TextBox ID="txtb_taskName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfv_taskName" runat="server" ControlToValidate="txtb_taskName"
ErrorMessage="Enter Task Name" ForeColor="#F60000">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Default Tech:
</td>
<td>
<asp:Literal ID="lit_dafaultTech" runat="server"></asp:Literal>
</td>
</tr>
<tr>
<td>
<label>
Assigned To :</label><em>*</em>
</td>
<td>
<asp:DropDownList ID="ddl_usersList" runat="server" AppendDataBoundItems="True" DataSourceID="SqlDataSourceUserList"
DataTextField="UserName" DataValueField="UserId">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddl_usersList"
CssClass="Validator" ErrorMessage="select Tech" InitialValue="-1">*</asp:RequiredFieldValidator>
<asp:SqlDataSource ID="SqlDataSourceUserList" runat="server" ConnectionString="<%$ ConnectionStrings:Compudata_ProjectManagerConnection %>"
SelectCommand="SELECT [UserId], [UserName] FROM [vw_aspnet_Users]"></asp:SqlDataSource>
</td>
</tr>
<tr>
<td>
<label>
Status :</label><em>*</em>
</td>
<td>
<asp:DropDownList ID="ddl_status" runat="server" AppendDataBoundItems="True">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ddl_status"
ErrorMessage="select Status" InitialValue="-1" CssClass="Validator">*</asp:RequiredFieldValidator>
<asp:SqlDataSource ID="status_sqlDS" runat="server" ConnectionString="<%$ ConnectionStrings:Compudata_ProjectManagerConnection %>"
SelectCommand="GetAllStatus" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</td>
</tr>
<tr>
<td>
<label>
Priorty:</label><em>*</em>
</td>
<td>
<asp:DropDownList ID="ddl_priority" runat="server" AppendDataBoundItems="True">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="ddl_priority"
ErrorMessage="Select one" CssClass="Validator" InitialValue="-1">*</asp:RequiredFieldValidator>
<asp:SqlDataSource ID="priority_sqlDC" runat="server" ConnectionString="<%$ ConnectionStrings:Compudata_ProjectManagerConnection %>"
SelectCommand="GetAllPriority" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</td>
</tr>
<tr>
<td>
<label>
Estimate Time eg(1.50):</label>
</td>
<td>
<asp:TextBox ID="txtb_estTime" runat="server" Style="direction: ltr"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<label>
Description:</label><em>*</em>
</td>
<td>
<asp:TextBox ID="txtb_Description" runat="server" TextMode="MultiLine"
Width="600px" Height="300px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td colspan="2">
<label>
Send Email:
</label>
<asp:CheckBox ID="ch_sendEmail" runat="server" Text="Send Email to assigned Tech"
Checked="True" />
</td>
</tr>
<tr>
<td>
<label>Start Date: </label>
</td>
<td>
<asp:TextBox ID="txtb_startDate" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<label>End Date: </label>
</td>
<td>
<asp:TextBox ID="txtb_endDate" runat="server" CssClass=".datetimepicker"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<label>show on Calendar </label>
</td>
<td>
<asp:CheckBox ID="chb_calendar" runat="server" Text="show on Calendar"></asp:CheckBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblMessage" runat="server"></asp:Label>
</td>
<td>
<asp:Button ID="btn_createTask" runat="server" Text="Create Task" OnClick="createTask_Click" />
<asp:Button ID="Button2" runat="server" Text="Cancel" />
</td>
</tr>
</table>
<br />
<!-- begin of Web template option -->
<table class="style1">
<tr>
<td>
<asp:LinkButton ID="lnkb_clientRMA" runat="server"
onclick="lnkb_clientRMA_Click"
>CLIENT RMA RETURN</asp:LinkButton> </td>
<td>
<asp:LinkButton ID="lnkb_LG_SERVICE" runat="server"
onclick="lnkb_LG_SERVICE_Click">LG SERVICE</asp:LinkButton> </td>
<td>
<asp:LinkButton ID="lnkb_PHONE_REMOTESUPPORT" runat="server"
onclick="lnkb_PHONE_REMOTESUPPORT_Click">PHONE/REMOTE SUPPORT</asp:LinkButton> </td>
<td>
<asp:LinkButton ID="lnkb_SEAGATE_RMA_RETURN" runat="server"
onclick="lnkb_SEAGATE_RMA_RETURN_Click">SEAGATE RMA RETURN</asp:LinkButton> </td>
<td>
<asp:LinkButton ID="lnkb_ON_SITE_SERVICE" runat="server"
onclick="lnkb_ON_SITE_SERVICE_Click"> ON-SITE SERVICE</asp:LinkButton></td>
<td>
<asp:LinkButton ID="lnkb_ZEISS_RMA_DIAGNOSTIC" runat="server"
onclick="lnkb_ZEISS_RMA_DIAGNOSTIC_Click">ZEISS RMA AND DIAGNOSTIC</asp:LinkButton> </td>
</tr>
<tr>
<td>
<asp:LinkButton ID="lnkb_LENOVO_SERVICE" runat="server"
onclick="lnkb_LENOVO_SERVICE_Click">LENOVO SERVICE</asp:LinkButton></td>
<td>
<asp:LinkButton ID="lnkb_MONTHLY_SERVICE" runat="server"
onclick="lnkb_MONTHLY_SERVICE_Click">MONTHLY SERVICE</asp:LinkButton> </td>
<td>
<asp:LinkButton ID="lnkb_Power_Supply_RMA" runat="server"
onclick="lnkb_Power_Supply_RMA_Click">Power Supply RMA</asp:LinkButton></td>
<td>
<asp:LinkButton ID="lnkb_IN_SHOP_SERVICE" runat="server"
onclick="lnkb_IN_SHOP_SERVICE_Click" >IN-SHOP SERVICE</asp:LinkButton></td>
<td>
<asp:LinkButton ID="lnkb_VENDOR_RMA_RETURN" runat="server"
onclick="lnkb_VENDOR_RMA_RETURN_Click">VENDOR RMA RETURN</asp:LinkButton></td>
<td>
</td>
</tr>
</table>
<!-- end of Web template option -->
</asp:Panel>
<!-- end of Content Create TaskForm -->
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddl_projectsList" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
you can place your web form in .aspx page and use this function this line will create iframe window
Scheduler.Lightbox.SetExternalLightboxForm("formName.aspx")
I'm trying to implement validation in my ASP.NET Webforms application. Right now, the only validator that works is for the Date of Birth (DOB) field. It is a custom field.
ASPX Code
<table>
<tr> <td align="center" colspan="2">
<asp:Label ID="RegisterTitleID" runat="server">Register here for your New Account </asp:Label></td>
</tr>
<tr>
<td align="right"> <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="EmailTextBox">E-mail:</asp:Label> </td>
<td> <asp:TextBox ID="EmailTextBox" runat="server" Height="25px" Width="200px"
CausesValidation="True"></asp:TextBox></td>
<asp:RequiredFieldValidator ID="EmailRequired" runat="server"
ControlToValidate="EmailTextBox" ErrorMessage="E-mail is required."
ToolTip="E-mail is required." ValidationGroup="RegistrationWizard"
Display="Dynamic">*</asp:RequiredFieldValidator> </tr>
<tr>
<td align="right"> <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="PasswordTextBox">Password:</asp:Label> </td>
<td> <asp:TextBox ID="PasswordTextBox" runat="server" TextMode="Password"
Height="25px" Width="200px" CausesValidation="True"></asp:TextBox></td>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
ControlToValidate="PasswordTextBox" ErrorMessage="Password is required."
ToolTip="Password is required." ValidationGroup="RegistrationWizard"
Display="Dynamic">*</asp:RequiredFieldValidator> </tr>
<tr>
<td align="right"> <asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPasswordTextBox">Confirm Password:</asp:Label> </td>
<td> <asp:TextBox ID="ConfirmPasswordTextBox" runat="server" TextMode="Password" Height="25px" Width="200px"></asp:TextBox></td>
<asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server"
ControlToValidate="ConfirmPasswordTextBox" ErrorMessage="Confirm Password is required."
ToolTip="Confirm Password is required." ValidationGroup="RegistrationWizard">*</asp:RequiredFieldValidator> </tr>
<tr>
<td align="center" colspan="2">
<asp:CompareValidator ID="PasswordCompare" runat="server"
ControlToCompare="PasswordTextBox" ControlToValidate="ConfirmPasswordTextBox"
Display="Dynamic"
ErrorMessage="The Password and Confirmation Password must match."
ValidationGroup="RegistrationWizard"> </asp:CompareValidator> </td> </tr>
<tr>
<td align="right"> <asp:Label ID="TitleLabel" runat="server" AssociatedControlID="TitleTextBox">Title:</asp:Label> </td>
<td> <asp:TextBox ID="TitleTextBox" runat="server" Height="25px" Width="200px"></asp:TextBox></td>
<asp:RequiredFieldValidator ID="TitleRequired" runat="server"
ControlToValidate="TitleTextBox" ErrorMessage="Title is required."
ToolTip="Title is required." ValidationGroup="RegistrationWizard">*</asp:RequiredFieldValidator> </tr>
<tr>
<td align="right"> <asp:Label ID="FirstNameLabel" runat="server" AssociatedControlID="FirstNameTextBox">First Name:</asp:Label> </td>
<td> <asp:TextBox ID="FirstNameTextBox" runat="server" Height="25px" Width="200px"></asp:TextBox></td>
<asp:RequiredFieldValidator ID="FirstNameRequired" runat="server"
ControlToValidate="FirstNameTextBox" ErrorMessage="First Name is required."
ToolTip="First Name is required." ValidationGroup="RegistrationWizard">*</asp:RequiredFieldValidator> </tr>
<tr>
<td align="right"> <asp:Label ID="SurnameLabel" runat="server" AssociatedControlID="SurnameTextBox">Surname:</asp:Label> </td>
<td> <asp:TextBox ID="SurnameTextBox" runat="server" Height="25px" Width="200px"></asp:TextBox></td>
<asp:RequiredFieldValidator ID="SurnameRequired" runat="server"
ControlToValidate="SurnameTextBox" ErrorMessage="Surname is required."
ToolTip="Surname is required." ValidationGroup="RegistrationWizard">*</asp:RequiredFieldValidator> </tr>
<tr>
<td align="right"> <asp:Label ID="DOBLabel" runat="server" AssociatedControlID="DOBTextBox">Date of Birth:</asp:Label> </td>
<td> <asp:TextBox ID="DOBTextBox" runat="server" Height="25px" Width="200px">dd/mm/yyyy</asp:TextBox>
</td>
<asp:RequiredFieldValidator ID="DOBRequired" runat="server"
ControlToValidate="DOBTextBox" ErrorMessage="Date of birth is required."
ToolTip="Date of birth is required." ValidationGroup="RegistrationWizard">*</asp:RequiredFieldValidator>
<asp:CustomValidator runat="server"
ID="DateRangeCustomValidator"
ControlToValidate="DOBTextBox"
onservervalidate="valDateRange_ServerValidate"
ErrorMessage="Enter a valid date. " />
</tr>
<tr>
<td align="right"> <asp:Label ID="GenderLabel" runat="server" AssociatedControlID="GenderDropDownList">Gender:</asp:Label> </td>
<td> <asp:DropDownList ID="GenderDropDownList" runat="server" AppendDataBoundItems="true" Height="27px" Width="205px">
<asp:ListItem Value="-1">Select</asp:ListItem>
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:DropDownList> </td>
<asp:RequiredFieldValidator ID="GenderRequired" runat="server"
ControlToValidate="GenderDropDownList" ErrorMessage="Gender is required."
ToolTip="Gender is required." ValidationGroup="RegistrationWizard">*</asp:RequiredFieldValidator>
</tr>
<tr>
<td align="right"> <asp:Label ID="PhoneNumberLabel" runat="server" AssociatedControlID="PhoneNumberTextBox">PhoneNumber:</asp:Label> </td>
<td> <asp:TextBox ID="PhoneNumberTextBox" runat="server" Height="25px" Width="200px"></asp:TextBox></td></tr>
<tr>
<td align="right"> <asp:Label ID="FavouriteTeamLabel" runat="server" AssociatedControlID="FavouriteTeamDropDownList">Favourite Team:</asp:Label> </td>
<td>
<asp:DropDownList ID="FavouriteTeamDropDownList" runat="server" DataSourceID="Team"
DataTextField="Team" DataValueField="Team" Height="27px" Width="205px">
</asp:DropDownList>
<asp:SqlDataSource ID="Team" runat="server"
ConnectionString="<%$ ConnectionStrings:RocoSportsDBConnectionString %>"
SelectCommand="SELECT [Team] FROM [Team]"></asp:SqlDataSource>
</td>
</tr>
<tr>
<td align="right"> <asp:Label ID="MaritialStatusLabel" runat="server" AssociatedControlID="MaritialStatusDropDownList">Maritial Status:</asp:Label> </td>
<td> <asp:DropDownList ID="MaritialStatusDropDownList" runat="server" AppendDataBoundItems="true" Height="27px" Width="205px">
<asp:ListItem Value="-1">Select</asp:ListItem>
<asp:ListItem>Single</asp:ListItem>
<asp:ListItem>Married</asp:ListItem>
<asp:ListItem>Separated</asp:ListItem>
<asp:ListItem>Unmarried Relationship</asp:ListItem>
<asp:ListItem>Domestic Partnership</asp:ListItem>
</asp:DropDownList> </td>
</tr>
<tr>
<td align="right"> <asp:Label ID="EducationLabel" runat="server" AssociatedControlID="EducationDropDownList">Education:</asp:Label> </td>
<td> <asp:DropDownList ID="EducationDropDownList" runat="server" AppendDataBoundItems="true" Height="27px" Width="205px">
<asp:ListItem Value="-1">Select</asp:ListItem>
<asp:ListItem>None</asp:ListItem>
<asp:ListItem>Primary School</asp:ListItem>
<asp:ListItem>Secondary School</asp:ListItem>
<asp:ListItem>College</asp:ListItem>
<asp:ListItem>Undergrad</asp:ListItem>
<asp:ListItem>Postgrad</asp:ListItem>
</asp:DropDownList> </td>
</tr>
<tr>
<td align="right"> <asp:Label ID="ProfessionLabel" runat="server" AssociatedControlID="ProfessionDropDownList">Profession:</asp:Label> </td>
<td> <asp:DropDownList ID="ProfessionDropDownList" runat="server" AppendDataBoundItems="true" Height="27px" Width="205px">
<asp:ListItem Value="-1">Select</asp:ListItem>
<asp:ListItem>None</asp:ListItem>
<asp:ListItem>Management</asp:ListItem>
<asp:ListItem>Professional</asp:ListItem>
<asp:ListItem>Armed Forces</asp:ListItem>
<asp:ListItem>Sales</asp:ListItem>
<asp:ListItem>Adminstrative</asp:ListItem>
<asp:ListItem>Farming</asp:ListItem>
<asp:ListItem>Construction</asp:ListItem>
</asp:DropDownList> </td>
</tr>
<tr>
<td align="right"> <asp:Label ID="SalaryLabel" runat="server" AssociatedControlID="SalaryDropDownList">Salary:</asp:Label> </td>
<td> <asp:DropDownList ID="SalaryDropDownList" runat="server" AppendDataBoundItems="true" Height="27px" Width="205px">
<asp:ListItem Value="-1">Select</asp:ListItem>
<asp:ListItem>None</asp:ListItem>
<asp:ListItem>5000</asp:ListItem>
<asp:ListItem>10000</asp:ListItem>
<asp:ListItem>20000</asp:ListItem>
<asp:ListItem>30000</asp:ListItem>
<asp:ListItem>50000</asp:ListItem>
<asp:ListItem>100000</asp:ListItem>
</asp:DropDownList> </td>
</tr>
<tr>
<td align="right"> <asp:Label ID="EmploymentStatusLabel" runat="server" AssociatedControlID="EmploymentStatusDropDownList">EmploymentStatus:</asp:Label> </td>
<td> <asp:DropDownList ID="EmploymentStatusDropDownList" runat="server" AppendDataBoundItems="true" Height="27px" Width="205px">
<asp:ListItem Value="-1">Select</asp:ListItem>
<asp:ListItem>Unemployed</asp:ListItem>
<asp:ListItem>Employed</asp:ListItem>
<asp:ListItem>Self-employed</asp:ListItem>
<asp:ListItem>Volunteer</asp:ListItem>
</asp:DropDownList> </td>
</tr>
<tr>
<td align="right"> <asp:Label ID="InterestsLabel" runat="server" AssociatedControlID="InterestsCheckBox">Interests:</asp:Label> </td>
<td>
<asp:CheckBoxList ID="InterestsCheckBox" runat="server"
onselectedindexchanged="InterestsCheckBox_SelectedIndexChanged">
<asp:ListItem>Reading</asp:ListItem>
<asp:ListItem>Football</asp:ListItem>
<asp:ListItem>Swimming</asp:ListItem>
<asp:ListItem>Basketball</asp:ListItem>
<asp:ListItem>Cooking</asp:ListItem>
<asp:ListItem>Music</asp:ListItem>
<asp:ListItem>Philosophy</asp:ListItem>
<asp:ListItem>Programming</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr> <td align="center" colspan="2" style="color:Red;"> <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal> </td> </tr>
<tr> <td align="center" colspan="2"> <asp:Button ID="RegisterButton" runat="server" Text="Register" onclick="registerbutton_Click"/> </td> </tr>
</table>
What could be the problem that's causing this code not to work, yet is not throwing any errors? Also, I'd like to position the validators better, and add color to them?
You are using a ValidationGroup for all your validators except the DOB Custom validator.
Add it to your custom validator and also the Register Button.
<asp:CustomValidator runat="server"
ID="DateRangeCustomValidator"
ControlToValidate="DOBTextBox"
onservervalidate="valDateRange_ServerValidate"
ErrorMessage="Enter a valid date. "
ValidationGroup="RegistrationWizard"/>
<asp:Button ID="RegisterButton" runat="server" Text="Register"
ValidationGroup="RegistrationWizard" onclick="registerbutton_Click"/>
You have ValidationGroup set on your validators but not on your button.