Hi,
I need to compare the values of fields in two columns in radgrid. one is the label field and another is the radnumeric textbox. I adding the validators to the radnumeric textbox at the itemcreated event.
I have set the radajax property properly.. comparsion does not happen properly..
Please give the suggestion for it..
I need to compare the values of fields in two columns in radgrid. one is the label field and another is the radnumeric textbox. I adding the validators to the radnumeric textbox at the itemcreated event.
I have set the radajax property properly.. comparsion does not happen properly..
Please give the suggestion for it..
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Data;
using
System.Collections.Specialized;
using
System.IO;
using
System.Configuration;
using
System.Collections;
using
Penson.Online.CostBasis.Business;
using
Penson.EnterpriseLibrary.Logging;
using
Telerik.Web.UI;
using
Penson.Online.Common;
using
System.Globalization;
namespace
Penson.Online.CostBasis.Web
{
public
partial
class
CostBasisLotSelection : System.Web.UI.Page
{
#region Private/Global Variables
CBLotSelection CBLotSelectionBusiness;
string
encryptedUserData =
string
.Empty;
string
encryptedUTC =
string
.Empty;
string
userType =
string
.Empty;
ConstantsAndEnumsCostBasis.WebUserType loggedInUserType;
#endregion
#region Events
//Button btnTaxLotGo;
//Button btnCustAcctNoGo;
int
sum = 0;
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected
void
Page_Load(
object
sender, EventArgs e)
{
try
{
//initiate log4net logging process
Log.Init();
//load private objecys/variables with data from Session
LoadDataFromSession();
#region Autheticate/Authorize page access
if
(!IsPostBack)
{
if
(!
string
.IsNullOrEmpty(Request.QueryString[
"param1"
]))
{
encryptedUserData = Request.QueryString[
"param1"
].ToString();
}
if
(!
string
.IsNullOrEmpty(Request.QueryString[
"param2"
]))
{
encryptedUTC = Request.QueryString[
"param2"
].ToString();
}
if
(encryptedUserData.Length == 0 || encryptedUTC.Length == 0)
{
RedirectToErrorPage(ConstantsAndEnumsCostBasis.BasisErrortype.NoAuthParamPassed);
}
//check for user authentication
if
(!AuthenticateUser(encryptedUserData, encryptedUTC))
{
// redirect to error page
RedirectToErrorPage(ConstantsAndEnumsCostBasis.BasisErrortype.UnAuthorized);
}
Log.Write(
"User Authentication successful"
, Log.LogMessageType.Info);
}
#endregion
/**** Depending on user type page level controls will be enabled/diasabled ****/
if
(loggedInUserType == ConstantsAndEnumsCostBasis.WebUserType.Firm)
{
if
(Page.IsPostBack)
{
if
(!txtCustAcctNo.Text.Equals(
string
.Empty))
{
btnGo.Enabled =
true
;
}
}
else
{
rgCostBasisTrades.Visible =
false
;
//btnUpdate.Visible = false;
btnTaxLotsGo.Enabled =
false
;
}
}
if
(loggedInUserType == ConstantsAndEnumsCostBasis.WebUserType.Correspondent || loggedInUserType == ConstantsAndEnumsCostBasis.WebUserType.User)
{
if
(Page.IsPostBack)
{
//do Something
}
else
{
//do Something
}
}
}
catch
(Exception ex)
{
Log.Write(
"Execution Fail in CostBasis Lot Selection Page Load"
, Log.LogMessageType.Error, ex);
throw
;
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected
void
rgCostBasisTrades_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.ExpandCollapseCommandName)
{
GridDataItem dataItem = (GridDataItem)e.Item;
LinkButton btnLotUpdate = (LinkButton)dataItem[
"LotUpdate"
].Controls[0];
Label lblshares = dataItem[
"Shares"
].FindControl(
"lblmain"
)
as
Label;
//Label lblshares = (Label)dataItem.FindControl["lblmain"];
//insert custom logic here
if
(e.Item.Expanded)
{
btnLotUpdate.Enabled =
false
;
SetShouldInitializeNestedContent(btnLotUpdate.ClientID +
":"
+ lblshares.Text,
false
);
}
else
{
SetShouldInitializeNestedContent(btnLotUpdate.ClientID +
":"
+ lblshares.Text,
true
);
//if (e.Item.OwnerTableView.Name == "Taxlots")
//{
// if (e.Item is GridDataItem)
// {
// GridDataItem items = (GridDataItem)e.Item;
// RadNumericTextBox txtAllocation = items.FindControl("txtAllocation") as RadNumericTextBox;
// Label SharesLabel = items["Shares"].FindControl("lblShares") as Label;
// CompareValidator cmp = items.FindControl("CmptxtAllocation") as CompareValidator;
// //cmp.ValueToCompare = Math.Round(Convert.ToDecimal(SharesLabel.Text.ToString()), 2).ToString();
// cmp.ValueToCompare = Convert.ToString(Convert.ToInt32(SharesLabel.Text.ToString()));
// //cmp.ValueToCompare = "100";
// // cmp.c
// // Get the textbox for column Price
// txtAllocation.Attributes.Add("OnBlur", "return calculate('" + txtAllocation.ClientID + "','" + 100 + "','" + btnLotUpdate.ClientID + "')");
// // txtAllocation.Attributes.Add("onFocusout", "return calculate('" + txtAllocation.ClientID + "','" + 100 + "')");
// // txtPrice.Attributes.Add("onFocusout", "return calculate('" + txtPrice.ClientID + "','" + txtQuantity.ClientID + "','" + txtTotalAmount.ClientID + "')");
// // txtQuantity.Attributes.Add("onFocusout", "return calculate('" + txtPrice.ClientID + "','" + txtQuantity.ClientID + "','" + txtTotalAmount.ClientID + "')");
// // txtTotalAmount.Attributes.Add("onfocus", "return calculate('" + txtPrice.ClientID + "','" + txtQuantity.ClientID + "','" + txtTotalAmount.ClientID + "')");
// //}
// }
//}
}
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected
void
btnGo_Click(
object
sender, EventArgs e)
{
btnTaxLotsGo.Enabled =
true
;
pnlTaxLotsSearch.Enabled =
true
;
}
/// <summary>
///
/// </summary>
/// <param name="strValue"></param>
void
ucTaxLotsSearch_btnHandler(
string
strValue)
{
}
/// <summary>
///
/// </summary>
/// <param name="strValue"></param>
void
ucCustAcctDetails_btnCustAcctNoHandler(
string
strValue)
{
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected
void
btnTaxLotGo_Click(
object
sender, EventArgs e)
{
PopulateGrid();
}
//void ucTaxLotSearch_btnHandler(string strValue)
//{
//}
//void ucCostBasisDetail_btnCustAcctNoHandler(string strValue)
//{
//}
protected
void
rgCostBasisTrades_NeedDataSource(
object
source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
if
(Session[
"ReportDefinitionGridView1"
] !=
null
)
{
DataSet gridViewRptDef =
this
.Session[
"ReportDefinitionGridView1"
]
as
DataSet;
rgCostBasisTrades.DataSource = gridViewRptDef;
rgCostBasisTrades.DataMember =
"catalog"
;
}
}
protected
List<
string
> ExpandedItemKeys
{
get
{
if
(ViewState[
"ExpandedItemKeys"
] ==
null
)
{
ViewState[
"ExpandedItemKeys"
] =
new
List<
string
>();
}
return
(List<
string
>)ViewState[
"ExpandedItemKeys"
];
}
}
protected
void
SetShouldInitializeNestedContent(
string
item,
bool
shouldInitialize)
{
//GridDataItem dataItem = (GridDataItem)item;
//LinkButton lotlink = (LinkButton)dataItem.FindControl("LotUpdate");
string
dataValue = item;
if
(shouldInitialize && !ExpandedItemKeys.Contains(dataValue))
{
ExpandedItemKeys.Add(dataValue);
}
else
if
(!shouldInitialize && ExpandedItemKeys.Contains(dataValue))
{
ExpandedItemKeys.Remove(dataValue);
}
}
protected
void
SetShouldInitializeNestedContent(GridDataItem item,
bool
shouldInitialize)
{
GridDataItem dataItem = (GridDataItem)item;
LinkButton lotlink = (LinkButton)dataItem.FindControl(
"LotUpdate"
);
string
dataValue = lotlink.ClientID;
if
(shouldInitialize && !ExpandedItemKeys.Contains(dataValue))
{
ExpandedItemKeys.Add(dataValue);
}
else
if
(!shouldInitialize && ExpandedItemKeys.Contains(dataValue))
{
ExpandedItemKeys.Remove(dataValue);
}
}
void
PopulateGrid()
{
rgCostBasisTrades.Visible =
true
;
//btnUpdate.Visible = true;
string
myXMLfile = ConfigurationManager.AppSettings[
"CBLotSelection"
];
DataSet ds =
new
DataSet();
try
{
ds.ReadXml(myXMLfile);
this
.Session[
"ReportDefinitionGridView1"
] = ds;
rgCostBasisTrades.Rebind();
}
catch
(Exception ex)
{
}
}
protected
void
rgCostBasisTrades_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item.OwnerTableView.Name ==
"Taxlots"
)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
RadNumericTextBox txtAllocation = item.FindControl(
"txtAllocation"
)
as
RadNumericTextBox;
RadNumericTextBox SharesLabel = item[
"Shares"
].FindControl(
"txtShares"
)
as
RadNumericTextBox;
TableCell cell = (TableCell)txtAllocation.Parent;
txtAllocation.CausesValidation =
true
;
CompareValidator val =
new
CompareValidator();
val.ControlToCompare = SharesLabel.ID;
val.ControlToValidate = txtAllocation.ID;
val.Operator = ValidationCompareOperator.LessThan;
val.Display = ValidatorDisplay.Dynamic;
val.ErrorMessage =
"Error message"
;
cell.Controls.Add(val);
//CompareValidator cmp = item.FindControl("CmptxtAllocation") as CompareValidator;
////cmp.ValueToCompare = Math.Round(Convert.ToDecimal(SharesLabel.Text.ToString()), 2).ToString();
////cmp.ValueToCompare = Convert.ToString(Convert.ToInt32(SharesLabel.Text.ToString()));
//cmp.ValueToCompare = "100";
// cmp.c
// Get the textbox for column Price
//txtAllocation.Attributes.Add("onFocusout", "return calculate('" + txtAllocation.ClientID + "','" + 100 + "','" + txtTotalAmount.ClientID + "')");
// txtAllocation.Attributes.Add("onFocusout", "return calculate('" + txtAllocation.ClientID + "','" + 100 + "')");
// txtPrice.Attributes.Add("onFocusout", "return calculate('" + txtPrice.ClientID + "','" + txtQuantity.ClientID + "','" + txtTotalAmount.ClientID + "')");
// txtQuantity.Attributes.Add("onFocusout", "return calculate('" + txtPrice.ClientID + "','" + txtQuantity.ClientID + "','" + txtTotalAmount.ClientID + "')");
// txtTotalAmount.Attributes.Add("onfocus", "return calculate('" + txtPrice.ClientID + "','" + txtQuantity.ClientID + "','" + txtTotalAmount.ClientID + "')");
//}
}
}
}
protected
void
rgCostBasisTrades_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item.OwnerTableView.Name ==
"TaxlotsMain"
)
// check with name of DetailTable
{
if
(e.Item
is
GridDataItem)
{
GridDataItem dataItem = (GridDataItem)e.Item;
LinkButton btnLotUpdate = (LinkButton)dataItem[
"LotUpdate"
].Controls[0];
if
(e.Item.Expanded)
{
btnLotUpdate.Enabled =
true
;
}
else
{
btnLotUpdate.Enabled =
false
;
}
}
}
else
if
(e.Item.OwnerTableView.Name ==
"Taxlots"
)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
RadNumericTextBox txtAllocation = item.FindControl(
"txtAllocation"
)
as
RadNumericTextBox;
Label SharesLabel = item[
"Shares"
].FindControl(
"lblShares"
)
as
Label;
sum +=
int
.Parse(txtAllocation.Value.ToString());
// CompareValidator cmp = item.FindControl("CmptxtAllocation") as CompareValidator;
// //cmp.ValueToCompare = Math.Round(Convert.ToDecimal(SharesLabel.Text.ToString()), 2).ToString();
// //cmp.ValueToCompare = Convert.ToString(Convert.ToInt32(SharesLabel.Text.ToString()));
// cmp.ValueToCompare = "100";
//// cmp.c
// Get the textbox for column Price
string
[] Allc = ExpandedItemKeys[0].Split(
':'
);
txtAllocation.Attributes.Add(
"onFocusout"
,
"return calculate('"
+ txtAllocation.ClientID +
"','"
+ SharesLabel.ClientID +
"','"
+ Allc[0] +
"','"
+ Allc[1] +
"')"
);
// txtAllocation.Attributes.Add("onFocusout", "return calculate('" + txtAllocation.ClientID + "','" + 100 + "')");
// txtPrice.Attributes.Add("onFocusout", "return calculate('" + txtPrice.ClientID + "','" + txtQuantity.ClientID + "','" + txtTotalAmount.ClientID + "')");
// txtQuantity.Attributes.Add("onFocusout", "return calculate('" + txtPrice.ClientID + "','" + txtQuantity.ClientID + "','" + txtTotalAmount.ClientID + "')");
// txtTotalAmount.Attributes.Add("onfocus", "return calculate('" + txtPrice.ClientID + "','" + txtQuantity.ClientID + "','" + txtTotalAmount.ClientID + "')");
//}
}
else
if
(e.Item
is
GridFooterItem)
{
GridFooterItem footer = (GridFooterItem)e.Item;
RadNumericTextBox txtTotalAllocation = footer.FindControl(
"txtTotalAllocation"
)
as
RadNumericTextBox;
txtTotalAllocation.Value =
int
.Parse(sum.ToString());
txtTotalAllocation.Attributes.Add(
"OnLoad"
,
"return OnLoad()"
);
txtTotalAllocation.Visible =
false
;
// footer["ShipCity"].Controls.Add(new LiteralControl("<span style='color: Black; font-weight: bold;'>Total freight on this page is:</span> "));
// footer.FindControl("txtTotalAllocation") as RadNumericTextBox.Value = int.Parse(sum.ToString());
}
//GridDataInsertItem insertItem = (GridDataInsertItem)e.Item;
//GridDataItem parentitem = (GridDataItem)insertItem.OwnerTableView.ParentItem;
//GridTableView tableView = (GridTableView)parentitem.ChildItem.NestedTableViews[0];
//tableView.GetColumn("EditcolumnUniqueName").Visible = true;
//GridDataItem dataItem = (GridDataItem)ParentItem;
//foreach (GridDataItem dataItem in rgCostBasisTrades.Items)
// ((LinkButton)dataItem["EditcolumnUniqueName"].Controls[0]).Visible = false;
}
//else
//{
// foreach (GridDataItem parentitem in rgCostBasisTrades.Items)
// {
// if (parentitem.Expanded)
// {
// LinkButton btnLotUpdate = (LinkButton)parentitem["LotUpdate"].Controls[0];
// btnLotUpdate.Enabled = false;
// //GridTableView tableView = (GridTableView)parentitem.ChildItem.NestedTableViews[0];
// //tableView.GetColumn("EditcolumnUniqueName").Visible = false;
// }
// }
//}
//if (e.Item is GridDataItem)
//{
// GridDataItem dataItem = (GridDataItem)e.Item;
// LinkButton btnLotUpdate = (LinkButton)dataItem["LotUpdate"].Controls[0];
// btnLotUpdate.Enabled = false;
//}
//GridDataInsertItem insertItem = (GridDataInsertItem)e.Item;
//GridDataItem parentitem = (GridDataItem)insertItem.OwnerTableView.ParentItem;
//GridTableView tableView = (GridTableView)parentitem.ChildItem.NestedTableViews[0];
//tableView.GetColumn("EditcolumnUniqueName").Visible = true;
//GridDataItem dataItem = (GridDataItem)ParentItem;
//foreach (GridDataItem dataItem in rgCostBasisTrades.Items)
// ((LinkButton)dataItem["EditcolumnUniqueName"].Controls[0]).Visible = false;
//else
//{
// foreach (GridDataItem parentitem in rgCostBasisTrades.Items)
// {
// if (parentitem.Expanded)
// {
// LinkButton btnLotUpdate = (LinkButton)parentitem["LotUpdate"].Controls[0];
// btnLotUpdate.Enabled = false;
// //GridTableView tableView = (GridTableView)parentitem.ChildItem.NestedTableViews[0];
// //tableView.GetColumn("EditcolumnUniqueName").Visible = false;
// }
// }
//}
//if (e.Item is GridDataItem)
//{
// GridDataItem dataItem = (GridDataItem)e.Item;
// LinkButton btnLotUpdate = (LinkButton)dataItem["LotUpdate"].Controls[0];
// btnLotUpdate.Enabled = false;
//}
}
protected
void
rgCostBasisTrades_DetailTableDataBind(
object
source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
switch
(e.DetailTableView.Name)
{
case
"Taxlots"
:
{
LinkButton btnLotUpdate = (LinkButton)dataItem[
"LotUpdate"
].Controls[0];
btnLotUpdate.Enabled =
true
;
string
myXMLfile = ConfigurationManager.AppSettings[
"CBLotSelection2"
];
//Path.Combine(Environment.CurrentDirectory, @"CostBasis\XML\SampleXML21.xml"); //"C:\\Documents and Settings\\SPuttappa\\My Documents\\Visual Studio 2008\\Projects\\CostBasis\\XML\\SampleXML21.xml";
DataSet ds =
new
DataSet();
try
{
ds.ReadXml(myXMLfile);
e.DetailTableView.DataSource = ds;
e.DetailTableView.DataMember =
"catalog"
;
}
catch
(Exception ex)
{
}
break
;
}
}
}
protected
void
rgCostBasisTrades_UpdateCommand(
object
source, GridUpdatedEventArgs e)
{
}
protected
void
rgCostBasisTrades_UpdateCommand1(
object
source, GridCommandEventArgs e)
{
//e.Item.OwnerTableView.ParentItem.OwnerTableView.Rebind();
}
#endregion
#region Web Methods
/// <summary>
/// Authenticates the user
/// </summary>
/// <param name="encryptedUserData">encrypted User Data from ClientSite</param>
/// <param name="encryptedUTC">Encrypted DateTime</param>
/// <returns></returns>
private
bool
AuthenticateUser(
string
encryptedUserData,
string
encryptedUTC)
{
bool
timeOutErr =
false
;
string
[] userInfo;
bool
userAuthenticated =
false
;
int
utcDiff;
string
allowedUsers =
string
.Empty;
try
{
allowedUsers = ConfigurationManager.AppSettings[
"AllowedUserType"
].Trim();
if
(!Utility.IsProperUserInfo(encryptedUserData, encryptedUTC,
out
utcDiff,
out
timeOutErr,
out
userInfo))
{
if
(timeOutErr)
{
//unauthenticated user ... redirect to error page
string
iserr =
"User accessing the page after a time differernce of {0} minutes. User Not Authenticated."
;
iserr =
string
.Format(CultureInfo.InvariantCulture, iserr, Convert.ToString(utcDiff, CultureInfo.InvariantCulture));
try
{
throw
new
Exception(iserr);
}
catch
(Exception ex)
{
Log.Write(
"Execution Fail"
, Log.LogMessageType.Error, ex);
}
}
}
else
{
userType = userInfo[4];
// first check whether allowed
if
(allowedUsers.Contains(userType))
{
//user Authenticated & authorized
userAuthenticated =
true
;
//then assign the user type to the usable enum
switch
(userType)
{
case
"2"
:
loggedInUserType = ConstantsAndEnumsCostBasis.WebUserType.Firm;
break
;
case
"3"
:
loggedInUserType = ConstantsAndEnumsCostBasis.WebUserType.Correspondent;
break
;
case
"4"
:
loggedInUserType = ConstantsAndEnumsCostBasis.WebUserType.CorrespondentOffice;
break
;
case
"5"
:
loggedInUserType = ConstantsAndEnumsCostBasis.WebUserType.RegisteredRep;
break
;
case
"6"
:
loggedInUserType = ConstantsAndEnumsCostBasis.WebUserType.User;
break
;
}
}
Session[
"LoggedInUserType"
] = loggedInUserType;
}
}
catch
(Exception)
{
throw
;
}
return
userAuthenticated;
}
/// <summary>
/// Redirects to Custom error page
/// </summary>
public
void
RedirectToErrorPage(ConstantsAndEnumsCostBasis.BasisErrortype basisErrType)
{
try
{
Response.Redirect(
"Unauthorized.aspx?ErrorMsg="
+ basisErrType.ToString(),
true
);
}
catch
(Exception)
{
throw
;
}
}
/// <summary>
/// Loads the data from session
/// </summary>
private
void
LoadDataFromSession()
{
try
{
if
(Session[
"LoggedInUserType"
] !=
null
&& Session[
"LoggedInUserType"
].ToString().Length > 0)
{
loggedInUserType = (ConstantsAndEnumsCostBasis.WebUserType)Session[
"LoggedInUserType"
];
}
// Add code here to retrieve objects from Session
}
catch
(Exception)
{
throw
;
}
}
#endregion
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CostBasisLotSelection.aspx.cs" Inherits="Penson.Online.CostBasis.Web.CostBasisLotSelection" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
>Cost Basis Lot Selection Screen</
title
>
<
link
href
=
"css/Default.css"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
var sumInput = null;
var tempValue = 0;
function Load(sender, args) {
sumInput = sender;
tempValue = sender.GetValue();
// sumInput.set_value(tempValue);
}
function Blur(sender, args)
{
sumInput.set_value(tempValue + sender.GetValue());
}
function Focus(sender, args)
{
tempValue = sumInput.GetValue() - sender.GetValue();
//tempValue = sumInput.GetValue();
}
function letternumber(e) {
var key;
var keychar;
if (window.event)
key = window.event.keyCode;
else if (e)
key = e.which;
else
return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
// control keys
if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27))
return true;
// alphas and numbers
else if ((("abcdefghijklmnopqrstuvwxyz0123456789").indexOf(keychar) > -1))
return true;
else
return false;
}
function ClientValidate(source, arguments) {
var DateTo = document.getElementById("dtToDate_dateInput_text").value;
var DateFrom = document.getElementById("dtFromDate_dateInput_text").value;
var dtto = new Date(DateTo);
var dtFrom = new Date(DateFrom);
if (DateFrom == undefined) {
arguments.IsValid = true;
} else {
if (DateFrom > DateTo) {
arguments.IsValid = false;
} else {
arguments.IsValid = true;
}
}
}
function OnKeyPress(sender, eventArgs) {
var c = eventArgs.get_keyCode();
if ((c <
47
) || (c > 57))
eventArgs.set_cancel(true);
}
function calculate(price, quantity,Update,TotalShare) {
//alert(TotalAllocated);
var text1 = document.getElementById(price).value; //I used Asp.net Ajax find method
var text2 = document.getElementById(quantity).innerHTML;
var btnUpdate = $find(Update);
///alert(text1+'==='+text2);
var Input = $find(price);
//var totalAllocated = document.getElementById(TotalAllocated).value;
if(parseInt(text1) > parseInt(text2))
{
alert('Allocation Cannot Be More Than Avaiable Shares');
Input.clear();
return false;
}
else if (parseInt(sumInput.GetValue())>parseInt(TotalShare))
{
alert('Total Allocation Cannot Be More Than Total Avaiable Shares');
Input.clear();
btnUpdate.disable();
return false;
}
else
{
// btnUpdate.enable();
return true;
}
}
function ClientValidateTextbox(source, arguments)
{
}
</
script
>
</
telerik:RadCodeBlock
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"Scriptmanager1"
runat
=
"server"
>
</
asp:ScriptManager
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"btnGo"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"pnlTaxLotsSearch"
LoadingPanelID
=
"LoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"btnTaxLotsGo"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"rgCostBasisTrades"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"pnlTaxLotsSearch"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"rgCostBasisTrades"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"rgCostBasisTrades"
LoadingPanelID
=
"LoadingPanel3"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"LoadingPanel1"
runat
=
"server"
Style
=
"padding-top: 45px;padding-left: 35px;"
Height
=
"75px"
Width
=
"75px"
IsSticky
=
"false"
Transparency
=
"30"
>
<
img
alt
=
"Loading..."
src
=
"img/loadingReport.gif"
style
=
"border: 0;"
/>
</
telerik:RadAjaxLoadingPanel
>
<
telerik:RadAjaxLoadingPanel
ID
=
"LoadingPanel2"
runat
=
"server"
Style
=
"padding-top: 85px;padding-left: 15px;"
Height
=
"75px"
Width
=
"75px"
IsSticky
=
"false"
Transparency
=
"30"
>
<
img
alt
=
"Loading..."
src
=
"img/loadingReport.gif"
style
=
"border: 0;"
/>
</
telerik:RadAjaxLoadingPanel
>
<
telerik:RadAjaxLoadingPanel
ID
=
"LoadingPanel3"
runat
=
"server"
Style
=
"padding-top: 65px;padding-left: 20px;"
IsSticky
=
"false"
Transparency
=
"30"
>
<
img
alt
=
"Loading..."
src
=
"img/loadingReport.gif"
style
=
"border: 0;"
/>
</
telerik:RadAjaxLoadingPanel
>
<
table
border
=
"0"
cellpadding
=
"4"
cellspacing
=
"0"
width
=
"100%"
>
<
tr
class
=
"PageTitle"
valign
=
"middle"
>
<
td
>
<
span
id
=
"lblTitle"
class
=
"PageTitle"
>• Cost Basis Lot Selection Screen •</
span
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
table
width
=
"100%"
>
<
tr
>
<
td
>
<
table
width
=
"100%"
>
<
tr
>
<
td
style
=
"width: 33%"
>
<
asp:Panel
runat
=
"server"
ID
=
"pnlCustAcctNo"
Visible
=
"true"
GroupingText
=
"Customer Account Number"
Height
=
"55px"
Width
=
"100%"
HorizontalAlign
=
"Center"
>
<
table
>
<
tr
valign
=
"middle"
>
<
td
style
=
"height: 35px;width:65%"
>
<
asp:RequiredFieldValidator
ID
=
"rfdtxtCustAcctNo"
Display
=
"None"
runat
=
"server"
ControlToValidate
=
"txtCustAcctNo"
ValidationGroup
=
"gpUser"
ErrorMessage
=
" Enter Account Number"
></
asp:RequiredFieldValidator
>
<
telerik:RadTextBox
ID
=
"txtCustAcctNo"
MaxLength
=
"12"
Skin
=
"Office2007"
CssClass
=
"SMALLERTEXT"
OnKeyPress
=
"return letternumber(event);"
runat
=
"server"
>
</
telerik:RadTextBox
>
<
cc1:ValidatorCalloutExtender
ID
=
"valrqdFname_ValidatorCalloutExtender"
runat
=
"server"
Width
=
"15px"
TargetControlID
=
"rfdtxtCustAcctNo"
>
</
cc1:ValidatorCalloutExtender
>
</
td
>
<
td
>
<
asp:Button
ID
=
"btnGo"
Enabled
=
"true"
OnClick
=
"btnGo_Click"
ValidationGroup
=
"gpUser"
runat
=
"server"
BorderStyle
=
"None"
CssClass
=
"Buttons2"
Text
=
"Go"
/>
</
td
>
</
tr
>
</
table
>
</
asp:Panel
>
</
td
>
<
td
style
=
"width: 67%"
>
</
td
>
</
tr
>
</
table
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
table
width
=
"100%"
>
<
tr
>
<
td
style
=
"width: 83%"
>
<
asp:Panel
runat
=
"server"
ID
=
"pnlTaxLotsSearch"
Enabled
=
"false"
Visible
=
"true"
GroupingText
=
"Tax Lots Search"
Height
=
"110px"
HorizontalAlign
=
"Center"
>
<
table
class
=
"selectedPage"
width
=
"97%"
style
=
"height: 70px"
>
<
tr
>
<
td
>
<
asp:CustomValidator
ID
=
"cstValFrmDate"
runat
=
"server"
ControlToValidate
=
"dtFromDate"
ClientValidationFunction
=
"ClientValidate"
Display
=
"None"
ErrorMessage
=
"From Date should be Less than To Date"
ValidationGroup
=
"GpTaxLot"
>
</
asp:CustomValidator
>
</
td
>
</
tr
>
<
tr
align
=
"left"
>
<
td
style
=
"width: 24%"
>
<
asp:Label
ID
=
"lblTaxLots"
CssClass
=
"SMALLERTEXTBOLD1"
runat
=
"server"
Text
=
"Tax Lots :"
></
asp:Label
>
</
td
>
<
td
style
=
"width: 26%"
>
<
asp:RadioButtonList
ID
=
"rblSymbolCusip"
Height
=
"5px"
CssClass
=
"SMALLERTEXTBOLD1"
runat
=
"server"
RepeatDirection
=
"Horizontal"
>
<
asp:ListItem
Selected
=
"True"
Text
=
"Symbol"
Value
=
"S"
></
asp:ListItem
>
<
asp:ListItem
Text
=
"Cusip"
Value
=
"C"
></
asp:ListItem
>
</
asp:RadioButtonList
>
</
td
>
<
td
style
=
"width: 24%"
>
<
asp:Label
ID
=
"lblFromDate"
CssClass
=
"SMALLERTEXTBOLD1"
runat
=
"server"
Text
=
"From :"
></
asp:Label
>
</
td
>
<
td
style
=
"width: 24%"
>
<
asp:Label
ID
=
"lblToDate"
CssClass
=
"SMALLERTEXTBOLD1"
runat
=
"server"
Text
=
"To :"
></
asp:Label
>
</
td
>
<
td
style
=
"width: 2%"
>
</
td
>
</
tr
>
<
tr
valign
=
"top"
align
=
"left"
>
<
td
>
<
telerik:RadComboBox
ID
=
"cmdTaxLots"
runat
=
"server"
Width
=
"110px"
MarkFirstMatch
=
"True"
Skin
=
"Office2007"
ToolTip
=
"Select Tax Lots"
>
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
/>
<
telerik:RadComboBoxItem
Text
=
"Open Lots"
/>
<
telerik:RadComboBoxItem
Text
=
"Closed Lots"
/>
</
Items
>
</
telerik:RadComboBox
>
</
td
>
<
td
style
=
"width: 23%"
>
<
telerik:RadTextBox
ID
=
"txtSymbolCusip"
Width
=
"110px"
Skin
=
"Office2007"
CssClass
=
"SMALLERTEXT"
runat
=
"server"
>
</
telerik:RadTextBox
>
</
td
>
<
td
>
<
telerik:RadDatePicker
ID
=
"dtFromDate"
Width
=
"110px"
runat
=
"server"
ToolTip
=
"Select Date"
Skin
=
"Office2007"
Culture
=
"English (United States)"
>
<
dateinput
labelcssclass
=
"radLabelCss_Office2007"
DateFormat
=
"MM/dd/yyyy"
skin
=
"Office2007"
>
<
ClientEvents
OnKeyPress
=
"OnKeyPress"
/>
</
dateinput
>
<
calendar
showrowheaders
=
"False"
skin
=
"Office2007"
usecolumnheadersasselectors
=
"False"
userowheadersasselectors
=
"False"
viewselectortext
=
"x"
>
<
specialdays
>
<
telerik:RadCalendarDay
Date
=
""
IsToday
=
"True"
Repeatable
=
"Today"
>
<
ItemStyle
CssClass
=
"rcToday"
BorderColor
=
"Red"
BorderStyle
=
"NotSet"
/>
</
telerik:RadCalendarDay
>
</
specialdays
>
</
calendar
>
<
datepopupbutton
cssclass
=
"radPopupImage_Office2007"
/>
</
telerik:RadDatePicker
>
</
td
>
<
td
>
<
telerik:RadDatePicker
ID
=
"dtToDate"
Width
=
"110px"
ShowRowHeaders
=
"false"
runat
=
"server"
ToolTip
=
"Select Date"
Skin
=
"Office2007"
Culture
=
"English (United States)"
>
<
dateinput
labelcssclass
=
"radLabelCss_Office2007"
DateFormat
=
"MM/dd/yyyy"
skin
=
"Office2007"
>
<
ClientEvents
OnKeyPress
=
"OnKeyPress"
/>
</
dateinput
>
<
calendar
showrowheaders
=
"False"
skin
=
"Office2007"
usecolumnheadersasselectors
=
"False"
userowheadersasselectors
=
"False"
viewselectortext
=
"x"
>
<
specialdays
>
<
telerik:RadCalendarDay
Date
=
""
IsToday
=
"True"
Repeatable
=
"Today"
>
<
ItemStyle
CssClass
=
"rcToday"
BorderColor
=
"Red"
BorderStyle
=
"Solid"
/>
</
telerik:RadCalendarDay
>
</
specialdays
>
</
calendar
>
<
datepopupbutton
cssclass
=
"radPopupImage_Office2007"
/>
</
telerik:RadDatePicker
>
<
cc1:ValidatorCalloutExtender
ID
=
"ValidatorCalloutExtender1"
runat
=
"server"
Width
=
"30 px"
TargetControlID
=
"cstValFrmDate"
>
</
cc1:ValidatorCalloutExtender
>
</
td
>
<
td
>
<
asp:Button
ID
=
"btnTaxLotsGo"
runat
=
"server"
BorderStyle
=
"None"
CausesValidation
=
"true"
ValidationGroup
=
"GpTaxLot"
CssClass
=
"Buttons2"
OnClick
=
"btnTaxLotGo_Click"
Text
=
"Go"
/>
</
td
>
<
td
style
=
"width: 100px"
>
</
td
>
</
tr
>
</
table
>
</
asp:Panel
>
</
td
>
<
td
style
=
"width: 17%"
>
</
td
>
</
tr
>
</
table
>
</
td
>
</
tr
>
</
table
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
table
width
=
"90%"
style
=
"height:100%"
>
<
tr
>
<
td
>
<
telerik:RadGrid
ID
=
"rgCostBasisTrades"
runat
=
"server"
AllowMultiRowSelection
=
"false"
AllowPaging
=
"false"
ShowHeader
=
"true"
OnItemCommand
=
"rgCostBasisTrades_ItemCommand"
AllowSorting
=
"false"
OnNeedDataSource
=
"rgCostBasisTrades_NeedDataSource"
OnItemDataBound
=
"rgCostBasisTrades_ItemDataBound"
OnItemUpdated
=
"rgCostBasisTrades_UpdateCommand"
OnItemCreated
=
"rgCostBasisTrades_ItemCreated"
OnDetailTableDataBind
=
"rgCostBasisTrades_DetailTableDataBind"
AutoGenerateColumns
=
"False"
GridLines
=
"None"
Height
=
"200px"
LoadingTemplateTransparency
=
"25"
AlternatingItemStyle-BackColor
=
"AliceBlue"
Visible
=
"true"
Skin
=
"Office2007"
Width
=
"100%"
onupdatecommand
=
"rgCostBasisTrades_UpdateCommand1"
>
<
MasterTableView
TableLayout
=
"Fixed"
Name
=
"TaxlotsMain"
>
<
PagerStyle
Mode
=
"NumericPages"
Visible
=
"False"
/>
<
DetailTables
>
<
telerik:GridTableView
Name
=
"Taxlots"
ShowHeader
=
"true"
runat
=
"server"
Width
=
"100 %"
ShowFooter
=
"true"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Symbol"
HeaderButtonType
=
"TextButton"
HeaderText
=
"Symbol"
SortExpression
=
"Symbol"
UniqueName
=
"Symbol"
>
<
HeaderStyle
HorizontalAlign
=
"left"
Width
=
"20%"
/>
<
ItemStyle
HorizontalAlign
=
"left"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Shares"
HeaderButtonType
=
"TextButton"
HeaderText
=
"Shares"
SortExpression
=
"Shares"
UniqueName
=
"Shares"
>
<
HeaderStyle
HorizontalAlign
=
"left"
Width
=
"20%"
/>
<
ItemStyle
HorizontalAlign
=
"left"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblShares"
runat
=
"server"
Text='<%# Eval("Shares") %>' />
<%-- <
telerik:RadNumericTextBox
ID
=
"txtShares"
runat
=
"server"
Text='<%# Eval("Shares") %>' >
<
NumberFormat
GroupSeparator
=
""
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
> --%>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"LotID"
HeaderButtonType
=
"TextButton"
HeaderText
=
"LotID"
SortExpression
=
"LotID"
UniqueName
=
"LotID"
>
<
HeaderStyle
HorizontalAlign
=
"left"
Width
=
"20%"
/>
<
ItemStyle
HorizontalAlign
=
"left"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Allocation"
HeaderButtonType
=
"TextButton"
HeaderText
=
"Allocation"
SortExpression
=
"Allocation"
UniqueName
=
"Shares"
>
<
ItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"txtAllocation"
Font-Size
=
"xx-small"
runat
=
"server"
Width
=
"80%"
MinValue
=
"1"
MaxValue
=
"999999999"
Text='<%#DataBinder.Eval(Container.DataItem, "Allocation")%>'>
<
ClientEvents
OnBlur
=
"Blur"
OnFocus
=
"Focus"
/>
<
NumberFormat
GroupSeparator
=
""
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
>
<%-- <
asp:CompareValidator
ID
=
"CmptxtAllocation"
runat
=
"server"
ErrorMessage
=
"Enter Value Less Than Shares"
ControlToValidate
=
"txtAllocation"
Display
=
"Dynamic"
Operator
=
"LessThanEqual"
></
asp:CompareValidator
>
<
cc1:ValidatorCalloutExtender
ID
=
"ValidatorCalloutExtender1"
runat
=
"server"
Width
=
"50 px"
TargetControlID
=
"CmptxtAllocation"
>
</
cc1:ValidatorCalloutExtender
>--%>
</
ItemTemplate
>
<
HeaderStyle
HorizontalAlign
=
"left"
Width
=
"20%"
/>
<
ItemStyle
HorizontalAlign
=
"left"
/>
<
FooterStyle
HorizontalAlign
=
"Left"
Width
=
"20%"
/>
<
FooterTemplate
>
<
telerik:RadNumericTextBox
ID
=
"txtTotalAllocation"
Font-Size
=
"xx-small"
runat
=
"server"
MinValue
=
"1"
MaxValue
=
"999999999"
Width
=
"80%"
>
<%--<
ClientEvents
OnLoad
=
"Load"
/>--%>
<
NumberFormat
GroupSeparator
=
""
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
>
</
FooterTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Trade"
HeaderButtonType
=
"TextButton"
HeaderText
=
"Trade #"
SortExpression
=
"Trade"
UniqueName
=
"Trade"
>
<
HeaderStyle
HorizontalAlign
=
"left"
/>
<
ItemStyle
HorizontalAlign
=
"left"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"BS"
HeaderButtonType
=
"TextButton"
HeaderText
=
"B / S"
SortExpression
=
"BS"
UniqueName
=
"BS"
>
<
HeaderStyle
HorizontalAlign
=
"left"
/>
<
ItemStyle
HorizontalAlign
=
"left"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Allocation"
HeaderButtonType
=
"TextButton"
HeaderText
=
"Allocation"
SortExpression
=
"Allocation"
UniqueName
=
"Shares"
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"Symbol"
HeaderButtonType
=
"TextButton"
HeaderText
=
"Description"
SortExpression
=
"Symbol"
UniqueName
=
"Symbol"
>
<
HeaderStyle
HorizontalAlign
=
"left"
/>
<
ItemStyle
HorizontalAlign
=
"left"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Price"
HeaderButtonType
=
"TextButton"
HeaderText
=
"Price"
SortExpression
=
"Price"
UniqueName
=
"Price"
>
<
HeaderStyle
HorizontalAlign
=
"left"
/>
<
ItemStyle
HorizontalAlign
=
"left"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Shares"
HeaderButtonType
=
"TextButton"
HeaderText
=
"Shares"
SortExpression
=
"Shares"
UniqueName
=
"Shares"
>
<
HeaderStyle
HorizontalAlign
=
"left"
Width
=
"20%"
/>
<
ItemStyle
HorizontalAlign
=
"left"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblmain"
runat
=
"server"
Text='<%# Eval("Shares") %>' />
<%-- <
telerik:RadNumericTextBox
ID
=
"txtShares"
runat
=
"server"
Text='<%# Eval("Shares") %>' >
<
NumberFormat
GroupSeparator
=
""
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
> --%>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridButtonColumn
ButtonType
=
"LinkButton"
CommandName
=
"Update"
Text
=
"Update"
UniqueName
=
"LotUpdate"
>
<
HeaderStyle
Width
=
"60px"
/>
</
telerik:GridButtonColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
ClientEvents
/>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
/>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
FilterMenu
NotSelectedImageUrl
=
"~/Skins/GridSkin/Ice/NotSelectedMenu.gif"
SelectedImageUrl
=
"~/Skins/GridSkin/Ice/SelectedMenu.gif"
>
</
FilterMenu
>
</
telerik:RadGrid
>
</
td
>
</
tr
>
</
table
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"center"
>
<%--<
asp:Button
ID
=
"btnGridUpdate"
runat
=
"server"
CssClass
=
"Buttons"
Text
=
"Update"
BorderStyle
=
"None"
Height
=
"21px"
Width
=
"67px"
/>
<
asp:HiddenField
ID
=
"hdnActionButtonClicked"
Value
=
"false"
runat
=
"server"
/>--%>
</
td
>
</
tr
>
</
table
>
</
form
>
</
body
>
</
html
>