|
Step 1: Handle the GetUIData() method in the RecordControl class of AddOrdersPage.aspx. Use the
SetDataAccessSettingsParameterValue method to pass the value of the ASPX text box.
The SetDataAccessSettingsParameterValue method has two arguments. The first argument is a key and
the second argument is its value. In the code below, “MYKEY” is the key and its value is “myKeyValue”.
The SetDataAccessSettingsParameterValue method can be called in any methods and, in this example, is called
in the GetUIData() event in the AddOrdersPage class.
The DataAccessSettings class is used to retrieve the value of the ASPX text box in the Data Access
Layer. Override the GetUIData() method in the OrdersRecordControl class, located in:
.NET Framework 1.1:
|
...\<App Folder>\Orders\AddOrdersPage.Controls.cs or .vb
|
.NET Framework 2.0:
|
...\<App Folder>\App_Code\Orders\AddOrdersPage.Controls.cs or .vb
|
C#:
public override string ModifyRedirectUrl(string redirectUrl, string redirectArgument)
{
string myStr = this.ShipCountry.Text + this.ShipCity.Text;
redirectUrl = redirectUrl + "?myparam=" + myStr;
return base.ModifyRedirectUrl(redirectUrl, redirectArgument);
}
|
Visual Basic .NET:
Public Overrides Function ModifyRedirectUrl(ByVal redirectUrl As String, ByVal redirectArgument As String) As String
Dim myStr As String = (Me.ShipCountry.Text + Me.ShipCity.Text)
redirectUrl = (redirectUrl + ("?myparam=" + myStr))
return MyBase.ModifyRedirectUrl(redirectUrl, redirectArgument)
End Function
|
Step 2: Add the following code in the OrdersRecord class in the Data Access Layer. This code
overrides the default constructor with a newly defined OrderRecord_InsertedRecord() method. This
new method gets the DataAccessSetting object which contains the key value. In addition, the UserID
and Password can be retrieved from this object.
The OrdersRecord class is located in:
.NET Framework 1.1:
|
...\<Application Folder>\DataAccess\OrdersRecord.cs or .vb
|
.NET Framework 2.0:
|
...\<Application Folder>\App_Code\Business Layer\OrdersRecord.cs or .vb
|
C#:
public OrdersRecord()
{
this.InsertedRecord+= new
BaseClasses.IRecordWithTriggerEvents.InsertedRecordEventHandler(OrdersRecord_InsertedRecord);
}
private void OrdersRecord_InsertedRecord(object sender, System.EventArgs e)
{
DataAccessSettings dataAccessSettingsObj = DataAccessSettings.Current;
if(dataAccessSettingsObj.ContainsKey("MYKEY"))
{
String myKey = (String)dataAccessSettingsObj["MYKEY"];
String myUserID = dataAccessSettingsObj.SignedInUserId;
String myUserName = dataAccessSettingsObj.SignedInUserName;
//More code customization to fit your logic
}
}
|
Visual Basic .NET:
Public Sub New()
MyBase.New
AddHandler InsrtedRecord, AddressOf Me.OrdersRecord_InsertedRecord
End Sub
Private Sub OrdersRecord_InsertedRecord(ByVal sender As Object, ByVal e As System.EventArgs)
Dim dataAccessSettingsObj As DataAccessSettings = DataAccessSettings.Current
If dataAccessSettingsObj.ContainsKey("MYKEY") Then
Dim myKey As String = CType(dataAccessSettingsObj("MYKEY"),String)
Dim myUserID As String = dataAccessSettingsObj.SignedInUserId
Dim myUserName As String = dataAccessSettingsObj.SignedInUserName
‘More code customization to fit your logic
End If
End Sub
|
Note: You can retrieve the value of a control in any of the events available in the OrdersRecord
class based on where you want to add your business logic. The events available in the OrdersRecord
class are:
InsertingRecord
InsertedRecord
SavingRecord
SavedRecord
DeletingRecord
DeletedRecord
UpdatedRecord
UpdatingRecord
|