Friday, June 5, 2015

Dynamically enable or disable RequiredFieldValidator using JQuery.

Dynamically enable or disable RequiredFieldValidator using JQuery.
Javascript Code :-
<script type="text/javascript" src="../Scripts/jquery-1.10.2.js"></script>
$(document).ready(function () {
  var var_RFV_txtDate = $get('<%=RFV_txtDate.ClientID %>');
            var_RFV_txtDate.enabled = false;
            $('#<%=span_txtDate.ClientID %>').hide();
            ddlStatus_change();
        });

function ddlStatus_change() {
$('#<%=ddlStatus.ClientID %>').change(function () {
var var_ddlStatus = $("#<%=ddlStatus.ClientID %> option:selected").text();
var var_RFV_txtDate = $get('<%=RFV_txtDate.ClientID %>');
var var_txtReturnedDt = $get('<%=txtReturnedDt.ClientID %>');
      
if (var_ddlStatus.toLowerCase().indexOf("--select--") > -1) {
var_RFV_txtDate.enabled = true;
$('#<%=span_txtDate.ClientID %>').show();
}
else {
var_RFV_txtDate.enabled = false;
$('#<%=span_txtDate.ClientID %>').hide();
}
return false;
})
}

HTML Code :-
Closed date : <span id="span_txtDate" class="required" runat="server">*</span>
<asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RFV_txtDate" runat="server" ControlToValidate="txtDate" Display="None" ErrorMessage="Closed Date" ValidationGroup="ValGroup_Required" />

<asp:DropDownList ID="ddlStatus" runat="server">
<asp:ListItem Text="--Select--" Value="--Select--"></asp:ListItem>
<asp:ListItem Text="Draft" Value="Draft"></asp:ListItem>
<asp:ListItem Text="Open" Value="Open"></asp:ListItem>
<asp:ListItem Text="Close" Value="Close"></asp:ListItem>
</asp:DropDownList>

Wednesday, June 3, 2015

CAML Query filter between two dates

CAML Query filter between two dates

Method 1:-
</And><Geq><FieldRef Name='Created' /><Value Type='DateTime' IncludeTimeValue='FALSE'><Today OffsetDays='-91' /></Value></Geq></And>

Method 2: Without using OffsetDays :-
DateTime dtStart = DateTime.Now.AddDays(-2);
                string dtStartDate = dtStart.ToString("yyyy-MM-ddTHH:mm:ssZ");
                string dtEndDate = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ");

                Microsoft.SharePoint.Client.CamlQuery camlQuery = new CamlQuery();
                camlQuery.ViewXml = "<Where><And><Geq><FieldRef Name='Created' /><Value Type='DateTime' IncludeTimeValue='FALSE'>" + dtStartDate + "</Value></Geq>" + "<Leq><FieldRef Name='Created' /><Value Type='DateTime' IncludeTimeValue='FALSE'>" + dtEndDate + "</Value></Leq></And></Where>";

Method 3: With using OffsetDays :-
Microsoft.SharePoint.Client.CamlQuery camlQuery = new CamlQuery();
                camlQuery.ViewXml = "<Where><And><Geq><FieldRef Name='Created' /><Value Type='DateTime' IncludeTimeValue='FALSE'><Today OffsetDays='-91' /></Value></Geq>" + "<Leq><FieldRef Name='Created' /><Value Type='DateTime' IncludeTimeValue='FALSE'><Today OffsetDays='91' /></Value></Leq></And></Where>";

Method 4:-
SPQuery camlQuery = new SPQuery();
camlQuery.Query = "<Where><And><Geq><FieldRef Name="Created" /><Value Type="DateTime" IncludeTimeValue='FALSE'>" +SPUtility.CreateISO8601DateTimeFromSystemDateTime(ddtStartDate) + "</Value></Geq>" +
"<Leq><FieldRef Name="Created" /><Value Type="DateTime" IncludeTimeValue='FALSE'>" +
SPUtility.CreateISO8601DateTimeFromSystemDateTime(ddtEndDate) + "</Value></Leq></And></Where>";
SPListItemCollection collection = list.GetItems(query);

Featured Post

Mention a Channel or Team – Power Automate

Mention a Channel or Team – Power Automate graph.microsoft.com/v1.0/teams/{teamId}/channels/{channelId}/messages Channel: ---------- {   ...

Popular posts