Hi,
I have develop 2 screen which is quite similiar.
These screen allow user to enter some value in the textboxes given and and a RadInputManager to validate the data inputed.
1 screen is working fine but 1 screen are not.
The screen which is not working, is because of the javascript not able to get the RadInputManager instance.
This screen has 1 textbox only, this textbox will have different validation depends on the different parameter passed in.
Each parameter will use different validation for the textbox.
Below are my codes, please advice.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="~/Transaction/TransactionUpdate.aspx.cs" |
Inherits="Transaction.TransactionUpdate" %> |
<%@ 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 id="Head1" runat="server"> |
<title></title> |
<style type="text/css" media="all"> |
@import "/css/standard.css"; |
</style> |
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW" /><meta http-equiv="PRAGMA" content="NO-CACHE" /><meta http-equiv="CACHE-CONTROL" content="NO-CACHE" /><meta http-equiv="EXPIRES" content="-1" /> |
<script src="/js/jquery-1.2.6.min.js" type="text/javascript"></script> |
<script src="/js/common.js" type="text/javascript"></script> |
</head> |
<body> |
<form id="form1" runat="server" autocomplete="off"> |
<telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="Default, Label" /> |
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"> |
</telerik:RadAjaxLoadingPanel> |
<telerik:RadWindowManager ID="radWindowManager" runat="server"> |
</telerik:RadWindowManager> |
<asp:ScriptManager ID="ScriptManager1" runat="server"> |
</asp:ScriptManager> |
<script language="javascript" type="text/javascript"> |
Telerik.Web.UI.RadWindowUtils.Localization = |
{ |
"Close": '<asp:Literal ID="radClose" runat="server" Text="<%$Resources:Button, btnClose%>" />', |
"OK": '<asp:Literal ID="radOk" runat="server" Text="<%$Resources:Button, btnOk%>" />', |
"Cancel": '<asp:Literal ID="radCancel" runat="server" Text="<%$Resources:Button, btnCancel%>" />', |
"Yes": '<asp:Literal ID="radYes" runat="server" Text="<%$Resources:Common, rbtnYes%>" />', |
"No": '<asp:Literal ID="radNo" runat="server" Text="<%$Resources:Common, rbtnNo%>" />' |
}; |
</script> |
<telerik:RadInputManager ID="radMgr" runat="server"> |
<telerik:TextBoxSetting BehaviorID="text"> |
<Validation IsRequired="true" /> |
<TargetControls> |
<telerik:TargetInput ControlID="txtNewValue" /> |
</TargetControls> |
</telerik:TextBoxSetting> |
<telerik:NumericTextBoxSetting BehaviorID="numeric" MinValue="0" MaxValue="999999"> |
<Validation IsRequired="true" /> |
<TargetControls> |
<telerik:TargetInput ControlID="txtNewValue" /> |
</TargetControls> |
</telerik:NumericTextBoxSetting> |
</telerik:RadInputManager> |
<telerik:RadScriptBlock ID="scriptBlock1" runat="server"> |
<script language="javascript" type="text/javascript"> |
function GetRadWindow() |
{ |
var oWindow = null; |
if (window.radWindow) oWindow = window.radWindow; |
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; |
return oWindow; |
} |
function PopulateData() |
{ |
var oObject = GetRadWindow().argument; |
document.getElementById('hdnTransactionId').value = oObject.TransactionId; |
document.getElementById('hdnValueType').value = oObject.ValueType; |
document.getElementById('hdnOldValue').value = oObject.OldValue; |
document.getElementById('hdnOriginalValue').value = oObject.OriginalValue; |
$("#spanOriginalValue").text(oObject.OldValue); |
$("#spanTitle").text('<asp:Literal ID="ltrlUpdateTransaction" runat="server" Text="<%$ Resources:ltrlUpdateTransaction%>"></asp:Literal>'); |
$("#spanOriginal").text('<asp:Literal ID="ltrlOriginal" runat="server" Text="<%$ Resources:ltrlOriginal%>"></asp:Literal>'); |
$("#spanNewVaue").text('<asp:Literal ID="ltrlUpdated" runat="server" Text="<%$ Resources:ltrlUpdated%>"></asp:Literal>'); |
if (oObject.ValueType == 'ValueType1') |
{ |
document.getElementById('txtNewValue').setAttribute('maxLength', "6"); |
} |
else if (oObject.ValueType == 'ValueType2') |
{ |
document.getElementById('txtNewValue').setAttribute('maxLength', "10"); |
} |
SetMandatory(oObject.ValueType); |
} |
function Close(valueType, newValue) |
{ |
var arg = new Object(); |
arg.ValueType = valueType; |
arg.NewValue = newValue; |
var oWnd = GetRadWindow(); |
oWnd.close(arg); |
} |
function SetMandatory(valueType) |
{ |
if (IsInputManagerValid("<%=radMgr.ClientID %>")) |
{ |
var im = $find("<%=radMgr.ClientID %>"); |
var text = im.get_inputSettings('text'); |
var numeric = im.get_inputSettings('numeric'); |
if (valueType == 'ValueType1') |
{ |
text.set_isRequired(false); |
numeric.set_isRequired(true); |
} |
else if (valueType == 'ValueType2') |
{ |
text.set_isRequired(true); |
numeric.set_isRequired(false); |
} |
} |
} |
$(document).ready(function() |
{ |
PopulateData(); |
}); |
</script> |
</telerik:RadScriptBlock> |
<telerik:RadAjaxPanel ID="ajaxPnlTransactionUpdate" runat="server" EnableEmbeddedScripts="true" LoadingPanelID="RadAjaxLoadingPanel1"> |
<div id="divUpdateTransaction" runat="server"> |
<table width="98%" cellpadding="5px"> |
<tr> |
<td> |
<div> |
<h2> |
<span id="spanTitle"><asp:Literal ID="ltrlTitle" runat="server" Text="Update Transaction"></asp:Literal></span> |
</h2> |
<div> |
<table width="98%"> |
<tr> |
<td style="width: 70%"> |
<span id="spanOriginal"><asp:Literal ID="ltrlOriginal" runat="server"></asp:Literal></span> |
</td> |
<td style="width: 30%"> |
<span id="spanOriginalValue"><asp:Literal ID="ltrlOriginalValue" runat="server" Text=""></asp:Literal></span> |
</td> |
</tr> |
<tr> |
<td style="width: 70%"> |
<span id="spanNewVaue"><asp:Literal ID="ltrlNewVaue" runat="server"></asp:Literal></span> |
</td> |
<td style="width: 30%"> |
<asp:TextBox ID="txtNewValue" runat="server" Width="80px" MaxLength="10"></asp:TextBox> |
</td> |
</tr> |
</table> |
</div> |
<div class="clear"> |
|
</div> |
<div id="divButton" runat="server" style="width:90%"> |
<p class="buttons"> |
<asp:Button ID="btnSave" runat="server" Text="<%$ Resources:Button, btnSave %>" OnClick="btnSave_OnClick" /> |
<asp:Button ID="btnCancel" runat="server" Text="<%$ Resources:Button, btnCancel %>" OnClientClick="GetRadWindow().close()" /> |
</p> |
</div> |
<div id="hdnHidden"> |
<asp:HiddenField ID="hdnTransactionId" runat="server" /> |
<asp:HiddenField ID="hdnValueType" runat="server" /> |
<asp:HiddenField ID="hdnOldValue" runat="server" /> |
<asp:HiddenField ID="hdnOriginalValue" runat="server" /> |
<asp:HiddenField ID="hdnTimeStampId" runat="server" /> |
</div> |
</div> |
</td> |
</tr> |
</table> |
</div> |
</telerik:RadAjaxPanel> |
</form> |
</body> |
</html> |
using System; |
using System.Collections; |
using System.Collections.Generic; |
using System.Configuration; |
using System.Data; |
using System.Web; |
using System.Web.Security; |
using System.Web.UI; |
using System.Web.UI.HtmlControls; |
using System.Web.UI.WebControls; |
using System.Web.UI.WebControls.WebParts; |
using System.Xml.Linq; |
using Telerik.Web.UI; |
namespace Transaction |
{ |
public partial class TransactionUpdate : BasePage |
{ |
#region Variables |
string TransactionDetailsLastUserId = "TransactionDetailsLastUserId"; |
string TransactionDetailsTimeStampId = "TransactionDetailsTimeStampId"; |
#endregion |
#region Event Handlers |
protected void Page_Load(object sender, EventArgs e) |
{ |
} |
protected void btnSave_OnClick(object sender, EventArgs e) |
{ |
try |
{ |
string transactionID = hdnTransactionId.Value.ToString().Trim(); |
long? customerId = SessionManager.UserSettings.DataContext.CustomerID; |
string valueType = hdnValueType.Value.ToString().Trim(); |
string oldValue = hdnOldValue.Value.ToString().Trim(); |
string newValue = txtNewValue.Text.ToString().Trim(); |
long userId = SessionManager.UserSettings.AppUserID; |
//call to DB to fetch the corresponding TimestampId and Last User ID |
CommonFacade commonFacade = new CommonFacade(); |
DataSet dsValues = (DataSet)commonFacade.GetTimestampFromTransactionId(transactionID); |
long lastUserId = string.IsNullOrEmpty(dsValues.Tables[0].Rows[0]["Last_UserId"].ToString()) ? 0 : Convert.ToInt64(dsValues.Tables[0].Rows[0]["Last_UserId"]); |
byte[] oldTimeStampId = (byte[])dsValues.Tables[0].Rows[0]["Timestamp_Id"]; |
byte[] newTimeStampId = null; |
if (!object.Equals(oldValue.ToString().Trim(), newValue.ToString().Trim())) |
{ |
ReportBiz report = new ReportBiz(); |
newTimeStampId = report.TransactionValueUpdate(transactionID, valueType, newValue, userId, oldTimeStampId); |
Session[TransactionDetailsTimeStampId] = newTimeStampId; |
if (string.IsNullOrEmpty(newValue)) newValue = hdnOriginalValue.Value; |
} |
ScriptManager.RegisterStartupScript(Page, typeof(Page), "CloseWindow", "<script type=\"text/javascript\">Close('" + valueType + "', '" + newValue + "');</script>", false); |
} |
catch (BusinessException ex) |
{ |
this.ShowRadErrorAlert(ex.Key); |
} |
} |
#endregion |
} |
} |