Datetime error using datefield - html

I'm using ext.net 3 and i need to create datetime together but in this ext both time and date are not same.
<ext:DateField runat="server" ID="date1" MarginSpec="0 10 0 20" LabelAlign="Right" Format="yyyy-MM-dd h:i:s" FieldLabel="Gate In Date/Time" AllowBlank="false" IndicatorText="*" IndicatorCls="red-text"></ext:DateField>
The result is 2016-06-01 12:00:00
The date works fine but the time got some problem.

You are returning data from the DateField so the time is going to always be 12:00:00. Ext.Net includes a TimeField as well. It's a dropdown list of formatted times. Use both to have your user select Date & Time.
<ext:FieldContainer runat="server" FieldLabel="Pick Date & Time" Layout="HBoxLayout">
<Items>
<ext:DateField ID="DateField1" runat="server">
</ext:DateField>
<ext:ToolbarSeparator Width="5" />
<ext:TimeField ID="Timefield1" runat="server" Width="100">
</ext:TimeField>
</Items>
</ext:FieldContainer>

Related

Hit query on pagination in display tag

I use DisplayTag in my struts2 application and i want to hit query on clicking pagination.
Ex : When user click on the next page or any page then query is fire on action class.
FILE : displayTag.jsp
<display:table name="list1" sort="list" size="20" pagesize="5" id="table1" export="true" requestURI="" partialList="true">
<display:column property="no" group="1" sortable="true" headerClass="sortable"></display:column>
<display:column property="nam" group="2" sortable="true" headerClass="sortable"></display:column>
<display:column property="ct" group="3" sortable="true" headerClass="sortable" autolink="true"></display:column>
<display:setProperty name="export.excel.filename" value="diplayTag.xls"></display:setProperty>
<display:setProperty name="export.pdf.filename" value="diplayTag.pdf"></display:setProperty>
<display:setProperty name="export.csv.filename" value="diplayTag.csv"></display:setProperty>
<display:setProperty name="export.pdf" value="true"></display:setProperty>
</display:table>
I use request.setAttribute("list1", li); where i set all data in list1(ArrayList) and pass to the displayTag.jsp.
DisplayTag get all data and display in the table format. But my need is to pass only 5 data at a time and on clicking next page action class send other 5 data and so on.
I refer link : Display tag pagination problem
But i can not understand because i'm use MySql and also new on DisaplyTag.
DB : MySql
Framework : struts2
After researching and hard working i found answer.
FILE : displayTag.jsp
<display:table name="list1" sort="external" size="20" pagesize="5" id="table1" export="true" requestURI="disTag" partialList="true">
// code as above
</dispaly:table>
here requestURI="disTag" is a action name.
FILE : struts.xml
<action name="disTag" class="className">
<result name="success">/displayTag.jsp</result>
<result name="error">/error.jsp</result>
</action>
FILE : class file
page = Integer.parseInt(request.getParameter((new ParamEncoder("table1").encodeParameterName(TableTagParameters.PARAMETER_PAGE))));
if(page != 0)
{
start = (page - 1) * 5; //5 is row or data per page.
}
getData(start, 5); //getData is a method which store all data in ArrayList. Based on start index.

How to set current date in CalendarExtender

Requirement is simple.
How to set current date in CalendarExtender control.
<cal:CalendarExtender ID="calDate" runat="server" SelectedDate="2008-01-01" TargetControlID="txtDate" CssClass="CalendarExtender" Format="yyyy/MM/dd">
Here the selected date is 2008-01-01. I need to show current date instead of 2008-01-01
Appreciate your assistance
You just need to assign it in codebehind, for example in Page_Load:
if(!IsPostBack)
calDate.SelectedDate = DateTime.Today;
Another example using #Hutchonoid approach: example below illustrate how to correctly use ajaxcontrolTookKit CalendarExtender.
<ajaxControlToolKit:CalendarExtender runat="server"
id="cal1"
TargetControlID="txtDateFrom"
CssClass="MyCalendar ajax__calendar ajax__calendar_hover"
Format="dd/MM/yyyy"
PopupButtonID="imgControl"
PopupPosition="BottomRight"
SelectedDate="<%# DateTime.Today %>" >
</ajaxControlToolKit:CalendarExtender>
<asp:TextBox Type="text" ID="txtDateFrom" runat="server"></asp:TextBox>
<asp:ImageButton ID="imgControl" runat ="server" ImageUrl
="~/_icons/ajaxcalendar.png" />
Hope the above code snip-it helps or at least clarify the concept.

VBscipt date format

This is my query.
strSQL = "Select task,to_char(ddat,'dd/mm/yyyy') as ddat from task where guid = '"&lvGuid&"'"
'Response.write strSQL
objRS.Open strSQL, objConn
If objRS.RecordCount > 0 Then
strTask = objRS("task")
strDate = objRS("ddat")
Else
strTask = ""
strDate = ""
End If
This is the form that show that i wanted to display a text area if the people is finish their task after due date for asking the reason. But the problem is the if else statement cannot be run. The program not display the textarea when the person is over due date.
<form name="form1" method="post" action="taskconfirm.asp" >
<h2>Ticket : <input type="text" name="txtTask" value="<%=strTask%>" style="height:35px; font-size: 18pt; border:none;" readonly> </h2>
<p>Today's Date: <%=Date()%></p>
<p>Due Date: <%=strDate%></p>
<p>By reaching to this link, you have completed the ticket above. Please click the button below to confirm</p>
<br>
<!-- ASP IF ELSE CONDITION HERE DATE - OVERDUE -->
<%If Date() > strDate then %>
<%response.write("Please give a reason for ticket overdue :")%><br/>
<textarea type="text" name="txtreas" rows="4" cols="40" id="txtareaId"></textarea>
<%end if%>
<input type="submit" name="txtConfirm" value="Confirm" ">
</form>
I feel appreciate for anyone trying to help.Thanks a lot.
If the year comes last, VBScript interprets date literals as mm/dd/yyyy. Your SQL statement is formatting the date as dd/mm/yyyy, so it's going to get interpreted incorrectly (the months and days are going to get swapped).
For example, today is August 12, 2015. Your SQL statement is returning:
12/08/2015
But VBScript is seeing this date as December 8, 2015.
If you instead return the date as:
2015/08/12
Then VBScript won't be confused because the month always comes after the year when formatted with the year first (yyyy/mm/dd).

RangeValidation Throws error

I am using a range validation in asp for a date range...
<EditItemTemplate>
<asp:RequiredFieldValidator ID="RequiredFieldValidatordtmStartDateEdit" runat="server" ErrorMessage="Start Date is required" ControlToValidate="dtmStartDateEdit"></asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidatordtmStartDateEdit" runat="server" Type="String" ErrorMessage="Range is +/- 1 year" ControlToValidate="dtmStartDateEdit" MaximumValue="DATETIME.Today.ADDYEARS(1).ToShortDateString()" MinimumValue="DATETIME.Today.ADDYEARS(-1).ToShortDateString()"></asp:RangeValidator>
<ajaxToolkit:CalendarExtender ID="CalendarExtenderStartDateEdit" runat="server" TargetControlID="dtmStartDateEdit"></ajaxToolkit:CalendarExtender>
<asp:TextBox ID="dtmStartDateEdit" runat="server">
</asp:TextBox>
</EditItemTemplate>
The error I get is that the Maximum cannot be smaller than the minimum.
Add type attribute , and I wonder ToShortDateString() returns String or use Type = Date if not.
<asp:RangeValidator ID="RangeValidatordtmCloseDateAdd" runat="server"
ErrorMessage="Range is +/- 1 year" ControlToValidate="dtmCloseDateAdd"
MaximumValue="DATETIME.Today.ADDYEARS(1).ToShortDateString()"
MinimumValue="DATETIME.Today.ADDYEARS(-1).ToShortDateString()"
Type = "String">
</asp:RangeValidator>
What I did was extract the Max and Min statements and placed them in the PageLoad event for each RangeValidator. It works fine.

Comparing date with exceptional date in asp.net Validator

I am using compare validator of asp.net to compare the Date, I am comparing input date with today's date for that I have written code as below.
<asp:CompareValidator ID="StartDateCompareVal" ValidationGroup="vgStep4" runat="server"
ControlToValidate="txtDueDate" Display="Dynamic" ErrorMessage="Dateshould be greater than today's date."
Operator="GreaterThan" ValueToCompare="<%# DateTime.Today.ToShortDateString() %>"
Type="Date"></asp:CompareValidator>
It is working fine, but Now my requirement is that if someone enters date as 00/00/0000 so, No need to compare the value and should be accepted
Looks like you might want to use a CustomValidator instead of the CompareValidator.
.aspx page:
<form id="frmAspnet" runat="server">
<asp:ValidationSummary runat="server" ID="vSummary" />
<div>
<label>
Enter Date Greater Than Today:
<asp:TextBox runat="server" ID="txtDate" />
</label>
</div>
<div>
<asp:Button runat="server" ID="cmdSubmit" Text="Submit" />
</div>
</form>
code behind:
private void cmdSubmit_Click(object sender, EventArgs e)
{
String validationGroup = "vgStep4";
vSummary.ValidationGroup = validationGroup;
Page.Validate(validationGroup);
DateTime dateEntered = DateTime.TryParse(txtDate.Text, out dateEntered) ? dateEntered : DateTime.MinValue;
Page.Validators.Add(new CustomValidator()
{
IsValid = (dateEntered > DateTime.Now.Date) || (txtDate.Text == "00/00/0000"),
ValidationGroup = validationGroup,
ErrorMessage = "Date should be greater than today's date."
});
if (Page.IsValid)
{
// Date entered is valid!
// or 00/00/0000 was entered
}
}