Entries in .Net Web Form (22)
How do I calculate the number of days from Today to a specified date on my web form?
Problem
I need a function that takes a date input (using the eWorld Calandar control) on a web form and calculates the number of days from today to that slected date and puts it into a field that I can then use as an OUT parameter. I need this for a lead time...
Solution
To use a calculated amount of time as an actions Lead Time, you will need to add the following code before the form is submitted to WorkflowGen (i.e.: within the submit button's "click" event):
C#
DateTime FromTime = DateTime.Today;
DateTime ToTime = MY_DATE_PICKER.SelectedDate;
TimeSpan DateDiff = ToTime - FromTime;
int TheLeadTime = DateDiff.Minutes;
this.MY_OUT_TEXTBOX_FOR_LEADTIMES.Text = TheLeadTime;
VB.NET
Dim FromTime As DateTime = DateTime.Today
Dim ToTime As DateTime = MY_DATE_PICKER.SelectedDate
Dim DateDiff As TimeSpan = (ToTime - FromTime)
Dim TheLeadTime As Integer = DateDiff.Minutes
Me.MY_OUT_TEXTBOX_FOR_LEADTIMES.Text = TheLeadTime
You may want to add some validation such as checking if ToTime is always > FromTime
Can we use other environments other than Microsoft Visual Studio to create our .NET forms?
Yes. You can use any development environment you are comfortable with as long as it supports ASP.NET and the Microsoft .NET 2.0 (or greater) Framework (for example, Visual Studio Web Developer).
Is it possible to change the Required and Read-Only field colors that workflowgen uses to different colors in my web form?
Yes, it is possible to change the colors used by WorkflowGen for the fields that are Required or Read-Only in your web forms. The WorkflowGen.My.dll contains a property for both that you can assign the colors you wish. you must include the proper
Add the following to your code in the Page_Load method:
C#
using System.Drawing;
public partial class _Default : WorkflowPage
{
protected void Page_Load(object sender, EventArgs e)
{
// set the read-only border color to Light Grey and required border color to Orange
this.ReadOnlyFieldsBorderColor = Color.FromArgb(210, 210, 210);
this.RequiredFieldsBorderColor = Color.Orange;
}
}
VB.NET
Imports System.Drawing
Public Class _Default
Inherits WorkflowPage
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' set the read-only border color to Light Grey and required border color to Orange
Me.ReadOnlyFieldsBorderColor = Color.FromArgb(210, 210, 210)
Me.RequiredFieldsBorderColor = Color.Orange
End Sub
End Class
Can I develop web forms for my WorkflowGen processes using .Net Framework 3.5?
Yes, WorkflowGen, more specifically the WorkflowGen.My assembly supports development of web forms using the Microsoft .Net 3.5 Framework. This requires however that the same version of the framework be installed on the web server where WorkflowGen is located.
Why are my web forms getting a Time Out Expired error when I submit the form.
Web forms are session based and these sessions are automatically recycled by IIS every 20 minutes by default. To eliminate losing your data, you should add the following code to your web forms code-behind's page consctructor method.
C#
Example
public partial class _Default : WorkflowPage
{
public _Default() : base()
{
IsSimpleMode = true;
IsSessionLess = true;
}
}
VB.NET
Example
Public Class _Default
Inherits WorkflowPage
Public Sub New()
MyBase.New
IsSimpleMode = true
IsSessionLess = true
End Sub
End Class