|
Open BaseApplicationPage.cs (.vb) in either Visual Studio or Iron Speed Designer. This file is located in:
|
...\<App Name>\App_Code\Shared\BaseApplicationPage.cs (.vb)
|
To make the method available to every new Iron Speed Designer application, put it in the code templates folder, usually:
|
C:\Program Files\Iron Speed\Designer vX.X.X\ProjectTemplates\vs200X\cs(vb)\App_Code\Shared
|
Add the following RegisterAlert() method in the BaseApplicationPage class.
C#:
public void RegisterAlert(string key, string msg, bool roaming) {
if (!roaming) {
MiscUtils.RegisterJScriptAlert(this, key, msg);
} else {
Hashtable AlertQueue = this.Session["AlertQueue"] as Hashtable;
if (AlertQueue == null)
this.Session["AlertQueue"] = AlertQueue = new Hashtable();
AlertQueue.Add(key, msg);
}
}
|
Visual Basic .NET:
Public Sub RegisterAlert(ByVal key As String, ByVal msg As String, ByVal roaming As Boolean)
If Not roaming Then
MiscUtils.RegisterJScriptAlert(Me, key, msg)
Else
Dim AlertQueue As Hashtable = TryCast(Me.Session("AlertQueue"), Hashtable)
If AlertQueue = Nothing Then
AlertQueue = New Hashtable()
Me.Session("AlertQueue") = AlertQueue
End If
AlertQueue.Add(key, msg)
End If
End Sub
|
Locate the Control_ClearControls_PreRender() event handler in the BaseApplicationPage class.
Insert the code block “Display alert messages”.
C#:
protected void Control_ClearControls_PreRender(object sender, EventArgs e) {
this.ClearControlsFromSession();
// Display alert messages
Hashtable AlertQueue = this.Session["AlertQueue"] as Hashtable;
if (AlertQueue != null) {
foreach (Object key in AlertQueue.Keys) {
string msg = AlertQueue[key] as string;
MiscUtils.RegisterJScriptAlert(this, (string)key, msg);
}
AlertQueue.Clear();
}
}
|
Visual Basic .NET:
Protected Sub Control_ClearControls_PreRender(ByVal sender As Object, ByVal e As EventArgs)
Me.ClearControlsFromSession()
' Display alert messages
Dim AlertQueue As Hashtable = TryCast(Me.Session("AlertQueue"), Hashtable)
If AlertQueue <> Nothing Then
For Each key As Object In AlertQueue.Keys
Dim msg As String = TryCast(AlertQueue(key), String)
MiscUtils.RegisterJScriptAlert(Me, DirectCast(key, String), msg)
Next
AlertQueue.Clear()
End If
End Sub
|
Save and rebuild. Your application is now roaming ready.
|