How to check that entered date is less than or not in 22nd of every month in a calendar, if I choose 23 then give me an error message in asp.net
<tr>
<td>Select Date:</td>
<td> </td>
<td>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:TextBox ID="txtdate" runat="server" CssClass="form-control" placeholder="yyyy-mm-dd" ForeColor="Black" required="true"></asp:TextBox>
<asp:CalendarExtender ID="CalExt" runat="server" CssClass="cal_Theme1" TargetControlID="txtdate" PopupButtonID="txtdate" Format="yyyy-MM-dd" />
</td>
<td> </td>
<td> </td>
</tr>
This is my front-end code and please help to how to solve this
You might be looking for:
<ajaxToolkit:CalendarExtender ID="CalExt" runat="server" CssClass="cal_Theme1" TargetControlID="txtdate" PopupButtonID="txtdate" Format="yyyy-MM-dd" />
Instead of "<asp:CalendarExtender"
After you make that change, you can work out how to validate the date the user selects, which may require you to write a custom validator.
Related
I have a table with some information shown, but I would like to able to edit after I click the checkbox above.
<asp:Button ID="Backbtn" runat="server" Text="Back" Width="84px"
onclick="Backbtn_Click" />
<br /><br />
<asp:CheckBox ID="CheckBox1" runat="server" onclick="check" Text="Check"/>
<table class="T-Table" >
<tr>
<th colspan="6"><em>IT INTERNAL USE</em></th>
</tr>
<tr>
<td width="180px">Doc.No </td>
<td>:</td>
<td width="160px">
<asp:Label ID="DocNo" runat="server" Text="Label"></asp:Label>
</td>
<%-- <td width="180px">Job Complete Date </td>
<td>:</td>
<td width="160px">
</td> --%>
</tr>
<tr>
<td>Received Date :</td>
<td>:</td>
<td>
<asp:Label ID="RDate" runat="server" Text="Label"></asp:Label>
</td>
<td>Response Time (HR) :</td>
<td>:</td>
<td><asp:TextBox ID="Response_T" runat="server" TextMode="DateTimeLocal"></asp:TextBox>
</td>
</tr>
<tr>
<td>Remarks </td>
<td>:</td>
<td colspan="5"><asp:TextBox ID="Remarks" runat="server" Rows="5" TextMode="MultiLine"
Columns="80"></asp:TextBox></td>
</tr>
<tr>
<td>Cost charge to Department </td>
<td>:</td>
<td><asp:TextBox ID="Cost" runat="server" ></asp:TextBox></td>
<td>Status</td>
<td>:</td>
<td> <asp:DropDownList ID="Progress" runat="server">
<asp:ListItem Text="Done" Value="Done"></asp:ListItem>
<asp:ListItem Text="In Progress" Value="In Progress"></asp:ListItem>
<asp:ListItem Text="Pending" Value="Pending"></asp:ListItem>
</asp:DropDownList></td>
</tr>
Here are some html code. I would like to add a function so that all the information can be editable after I click the Checkbox.
Thank you
There is nothing to do with C# or Linq here (as you tagged).
Assuming you are working on an ASP.NET application
Enable the checkbox AutoPostback. ie, Set AutoPostback property of the checkbox to true.
Then on page load or checkbox checked change event, enable the textbox.
eg. name of text editor is txtRemarks and checkbox name to be chkRemarksEditor
on chkRemarksEditor Checked change event :-
txtRemarks.Enabled = chkRemarksEditor.Checked;
I'm creating a class schedule viewer that's populating data from the database. I'm using gridview but the way that I've got it is that it just displays each cell in one singlular large column. I want the format of
9 10 11 12 13 14 15 16 17 18
Mon
Tues
Wed
Thurs
Fri
This is how my data is formatted for one cell:
<asp:GridView ID="GridView2" ShowHeader="false" GridLines="None" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table style="border: 1px solid #A55129; background-color: #FFF7E7">
<tr>
<td style="width: 200px">
<table>
<tr>
<td>
<b>Class Code:</b>
</td>
<td>
<asp:Label ID="lblcode"
runat="server"
Text='<%#Eval("classCode") %>'>
</asp:Label>
</td>
</tr>
<tr>
<td>
<b>Day:</b>
</td>
<td>
<asp:Label ID="lblday"
runat="server"
Text='<%#Eval("day") %>'>
</asp:Label>
</td>
</tr>
<tr>
<td>
<b>Start Period:</b>
</td>
<td>
<asp:Label ID="lblstart"
runat="server"
Text='<%#Eval("periodStart") %>'>
</asp:Label>
</td>
</tr>
<tr>
<td>
<b>End Period:</b>
</td>
<td>
<asp:Label ID="lblend"
runat="server"
Text='<%#Eval("periodEnd") %>'>
</asp:Label>
</td>
</tr>
<tr>
<td>
<b>Teacher:</b>
</td>
<td>
<asp:Label ID="lblteacher"
runat="server"
Text='<%#Eval("teacherName") %>'>
</asp:Label>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
The above code displays one set of data from the database. But I have hundreds of these so you can imagine that the total format is one very long single column.
Can someone suggest how I can get gridview to display my suggested format and with the data in their respective cells e.g. Geography on Monday, starting at 9, ending at 11 will show up along the Monday row, over the 9 and 10 columns?
Honestly, I am not sure if GridView is the best (or a good) candidate for such a task. I would go with Ajax & Jquery oriented solution but not sure how comfortable you are with them. Here are several ASP.NET projects that might give you an idea:
http://code.daypilot.org/65101/timetable-tutorial-asp-net-c-vb-net
http://code.daypilot.org/34377/shift-scheduling-tutorial-asp-net-sql-server-c-vb-net
Thank you very much for taking the time to read this. I have an issue in which I was setting a default button for an ASP.NET page on page load from code behind, but now that I have multiple validation groups targeting one control, that is no longer working. Now, when I hit enter while in that control (textbox), validation for both groups are triggered minus the validation summary text.
Here is my examplefied code:
ASPX
<table>
<tr>
<td><asp:Textbox runat="server" ID="validateMe"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="firstValidator" runat="server" ErrorMessage="First check not valid" Text="*" ControlToValidate="validateMe" ValidationGroup="firstGroup"></asp:RequiredFieldValidator>
<td><asp:RequiredFieldValidator ID="secondValidator" runat="server" ErrorMessage="Second check not valid" Text="*" ControlToValidate="validateMe" ValidationGroup="secondGroup"></asp:RequiredFieldValidator>
</tr>
<tr>
<td><asp:Button runat="server" ID="firstButton" Text="V1" ValidationGroup="firstGroup"/></td>
<td><asp:Button runat="server" ID="secondButton" Text="V2" ValidationGroup="secondGroup"/></td>
</tr>
<table>
<asp:ValidationSummary ID="firstSummary" runat="server" ValidationGroup="firstGroup"/>
<asp:ValidationSummary ID="secondSummary" runat="server" ValidationGroup="secondGroup"/>
C#
protected void Page_Load(object sender, EventArgs e)
{
this.Form.DefaultButton = firstButton.UniqueID;
}
If I use this and hit 'Enter' while inside of the textbox without typing anything into it, then neither of the validation summaries will appear but I will have two asterisks next to the textbox (one for each group). If the user presses 'Enter' I would expect a full validation using only the first group which is supposed to be assigned to the DefaultButton (here, 'firstButton'). Is there any way to achieve this functionality and initiate the client-side validation that would have happened had the user clicked 'firstButton' instead?
I have also tried wrapping the whole table plus the validation summaries inside of an asp:Panel and setting the DefaultButton there, but I received the same results. Any help or pointers in the right direction would be greatly appreciated!
Set
EnableClientScript="false"
in RequiredFieldValidator control. It will help.
<asp:Panel runat="server" DefaultButton="secondButton">
<table>
<tr>
<td>
<asp:TextBox runat="server" ID="validateMe"></asp:TextBox></td>
<td>
<asp:RequiredFieldValidator ID="firstValidator" runat="server" ErrorMessage="First check not valid" Text="*" ControlToValidate="validateMe" EnableClientScript="false" ValidationGroup="firstGroup"></asp:RequiredFieldValidator>
</td>
<td>
<asp:RequiredFieldValidator ID="secondValidator" runat="server" ErrorMessage="Second check not valid" Text="*" ControlToValidate="validateMe" EnableClientScript="false" ValidationGroup="secondGroup"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Button runat="server" ID="firstButton" Text="V1" ValidationGroup="firstGroup" /></td>
<td>
<asp:Button runat="server" ID="secondButton" Text="V2" ValidationGroup="secondGroup" /></td>
</tr>
</table>
<asp:ValidationSummary ID="firstSummary" runat="server" ValidationGroup="firstGroup" />
<asp:ValidationSummary ID="secondSummary" runat="server" ValidationGroup="secondGroup" />
</asp:Panel>
I have a problem getting an <asp:UpdatePanel..> to work inside a <table>.. <tr> </tr> structure and I don't know why. When the UpdatePanel is commented out everything works fine, but when I un-comment the UpdatePanel the contents of the <tr> </tr> tag doesn't even show up in Visual Studio 2010. This content does display when I run the web page but the UpdatePanel doesn't work. Non of my other web pages in this project have this problem but, then again, I use <div>s instead of <table>s in them.
One other thing. The is in my MasterPage.
Here is my script:
<asp:UpdatePanel ID="W9UpdatePanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<tr>
<td colspan="6">
<div class="branchSetupSectionTitle">W-9 Information:</div>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btnDownloadW9Pdf" runat="server"
Text="Download W-9" onclick="btnDownloadW9Pdf_Click" AutoPostBack="True" />
<%--<asp:RegularExpressionValidator ID="RegularExpressionValidator24"
runat="server" ControlToValidate="txtFirstPaymentAmount" Display="Dynamic"
ErrorMessage="The dollar amount you entered is in the wrong format."
ForeColor="Red" ValidationExpression="^\d+(\.\d\d)?$">*</asp:RegularExpressionValidator>--%>
<asp:CheckBox ID="chkW9FormSubmitted" runat="server" AutoPostBack="True"
oncheckedchanged="chkW9FormSubmitted_CheckedChanged"
Text=" I have submitted this W-9 Form" />
</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</ContentTemplate>
</asp:UpdatePanel>
</tr>
The event fires for both the button and the checkbox but the entire page is refreshed.
Thanks for your help.
UpdatePanel needs to render a div or span in order to function correctly. Since neither of these elements can be rendered between table rows, UpdatePanel does not have a placeholder to render the postback response html, and thus it doesn't work.
A workaround in your case may be to see which part of your page does not need to be inside the update panel and leave it outside. You could leave just the contents of <td colspan="2"> inside the UpdatePanel.
<asp:ScriptManager ID="scm" runat="server">
</asp:ScriptManager>
<fieldset>
<legend>Truck Master Entry Form</legend>
<asp:UpdatePanel ID="upd1" runat="server">
<ContentTemplate>
<table cellpadding="2" cellspacing="1">
<tr>
<td align="right">
Truck no :
</td>
<td align="left">
<asp:TextBox ID="truckno" runat="server" Width="120px" Height="20px" />
</td>
</tr>
<tr>
<td align="right">
Size :
</td>
<td align="left">
<asp:DropDownList ID="drptrucksize" runat="server" Width="120px" Height="20px" DataValueField="WEIGHT"
DataTextField="SIZE" OnSelectedIndexChanged="drptrucksize_SelectedIndexChanged"
AutoPostBack="true" />
</td>
</tr>
<tr>
<td align="right">
Type :
</td>
<td align="left">
<asp:TextBox ID="txttrucktype" runat="server" Width="120px" Height="20px" />
</td>
</tr>
<tr>
<td align="right">
Weight :
</td>
<td align="left">
<asp:TextBox ID="txtweight" runat="server" Width="120px" Height="20px" />
</td>
</tr>
<tr>
<td align="right">
</td>
<td align="left">
<asp:Button ID="btnsave" runat="server" Text="Save" Width="100px" Height="50px" />
<asp:Button ID="btncancel" runat="server" Text="Cancel" Width="100px" Height="50px" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
The update panel need to be put outside the table. Look at
Mohammad Shahnawaz's code.
I have just created a website with a MasterPage. I have two conditions that will illustrate my problem:
Condition 1:
I have added a ModalPopupExtender on website.master. It has three fields and each field has a RequiredFieldValidator and a ValidatorCalloutExtender.
Condition 2:
I have a few different pages where you can click on a registration link. When you click the registration link, a registration form will appear. This form also has RequiredFieldValidators and ValidatorCalloutExtenders for each field.
Problem:
If I open a registration form and want to place my feedback, I click on the feedback button. The feedback modal popup displays. If I click on the submit button without filling the feedback form, it should give me the error in ValidatorCalloutExtender format on the ModalPopupExtender panel. However, it doesnt show me any error but the ValidatorCalloutExtender does show on the registation form along with respective validation.
<cc1:ModalPopupExtender CancelControlID="lnk_cancel" ID="popup_change_password" BackgroundCssClass="modalBackground"
runat="server" TargetControlID="ImageButton1" PopupControlID="panel_change_password">
</cc1:ModalPopupExtender>
<asp:Panel ID="panel_change_password" runat="server" Style="display: none; height: 400px;
width: 400px; padding-left:30px; background-repeat:no-repeat;" BackImageUrl="~/Images/background.gif">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td colspan="3" valign="top">
<table cellpadding="0" cellspacing="0" width="400px">
<tr>
<td align="right">
<asp:ImageButton ID="lnk_cancel" runat="server" ImageUrl="Images/close.gif" Height="30px"
Width="30px" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lbl_new_password" runat="server" Text="Your feedback is important to us."
CssClass="login_font1"></asp:Label>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl_name" runat="server" Text="Name" CssClass="Label_Styles"></asp:Label>
</td>
<td>
:
</td>
<td>
<asp:TextBox ID="txt_name" runat="server" CssClass="Textbox_Styles"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl_email" runat="server" Text="Email Address" CssClass="Label_Styles"></asp:Label>
</td>
<td>
:
</td>
<td>
<asp:TextBox ID="txt_email" runat="server" CssClass="Textbox_Styles"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl_comment" runat="server" Text="Comments" CssClass="Label_Styles"></asp:Label>
</td>
<td>
:
</td>
<td>
<asp:TextBox ID="txt_comment" runat="server" CssClass="Textbox_Styles" Height="120px"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
</table>
</asp:Panel>
Put the above code in an UpdatePanel with UpdateMode="Conditional" and ChildrenAsTriggers="False".
So it will look something like :
<asp:UpdatePanel ID="sbsModalExtenderUpdatePanel" runat="server" UpdateMode="Conditional"
Visible="False" ChildrenAsTriggers="False">
<ContentTemplate>
<asp:Panel ID="StepByStepBookingPanel" runat="server" Enabled="false" EnableViewState="false"
Style="display: block" CssClass="mediumModalPopup" ScrollBars="Auto" Width="800px"
Height="300px" ViewStateMode="Enabled">
<div id="clientCoordDiv" runat="server">
<table id="StepByStepTable" runat="server">
etc...
</table>
</div>
</asp:Panel>
<ajax:ModalPopupExtender ID="mpeStepByStepBooking" runat="server" BackgroundCssClass="modalBackground"
PopupControlID="StepByStepBookingPanel" CancelControlID="BtnCancel" OnCancelScript="ClearStepByStepPopup"
TargetControlID="hdnStepByStepButton" DropShadow="true" BehaviorID="modalwithinput" />
<asp:CompareValidator ID="ClientCoordinatorCompareValidator" runat="server" ErrorMessage="Please select a Client Coordinator"
ControlToValidate="ddlClientCoordinator" Display="None" Operator="NotEqual" SetFocusOnError="True"
Type="Integer" ValueToCompare="0" ValidationGroup="SelectionRequired">
</asp:CompareValidator>
<asp:CompareValidator ID="CVOCoordinatorCompareValidator" runat="server" ErrorMessage="Please select a CVO Coordinator"
ControlToValidate="ddlCVOCoordinator" Display="None" Operator="NotEqual" ValueToCompare="0"
Type="Integer" SetFocusOnError="True" ValidationGroup="SelectionRequired">
</asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="CompareClientCoordinatorExt" runat="server" Enabled="True"
TargetControlID="ClientCoordinatorCompareValidator" BehaviorID="ClientValidatorExt">
</ajax:ValidatorCalloutExtender>
<ajax:ValidatorCalloutExtender ID="CVOCoordinatorCompareValidatorExt" BehaviorID="CVOValidatorExt"
runat="server" Enabled="True" TargetControlID="CVOCoordinatorCompareValidator">
</ajax:ValidatorCalloutExtender>
</ContentTemplate>
</asp:UpdatePanel>
This will keep the dialog up while you validate it. Unfortunately, I do not have the full solution since my validator messages are not displaying. So far, from what I am getting on the Net it is a problem with the Ajax library. Ugly!
Oh well, hope this helps someone...