Transaction using data from multiple Web Forms ?

G

Guest

I have multiple web forms in my application. The user after logging on is
directed to form1 where he enters information desired. Once finished he is
directed to form2 and the same procedure goes on till form6. After user has
entered information in all 6 forms the information needs to be entered in the
database by performing a Transaction. If the data from any of the forms is
missing the Transaction is rolled back.

My query is where do i store the data from first five forms till i commit
the transaction?

Right now I am using a dataset, which I instatiated in form 1. As the user
is direcetd to form2 the data entered is stored in table1 which is added to
dataset, which in turn is stored in cache. In subsequent forms I add new
Tables to same Dataset and after finishing all the forms I am using the same
dataset to update the Database by carrying out a transaction in DataAdapters
UpdateCommand Object.

Is this the way I shall perform the transaction? Pls Guide. Pls specify the
correct methodology if I am doing it wrong.
 
J

J

Whether you switch between 6 different pages or use a panel control and keep
submitting 1 page in a wizard fashion is entirely up to you, store in your
datasets, store in session or use viewstate the important thing to get is
your validation correct so that it is physically impossible for users to
miss out fields or enter invalid data and then when you come to perform your
update, spawn a transaction and commit if successful else rollback if
failure.
Personally I like the tabbed approach using panels, yes there is a great
deal more going on in the page than anyone looking at it would think but
there is far less processing in the background as everything is still there
for you come the end ready to submit; circumstance, preference and any other
number of factors might sway your decision, one last comment though, I'd
tighten up your validation so that they simply can't submit the form
correctly if they miss critical fields, if it is not going to go into the
database because it is going to fail(rollback) what is the point of allowing
them to submit the form anyway?

regards,
J.
 
G

Guest

Thanx for the response J.

I understand your stress on performing validation properly and I'll surely
try my best at it. Even, I was toying with the idea of using some sort of
tabs on my form, but i couldn't find any Tab controls. And i have no clue how
to go about creating one.

I would appreciate if you could explain it to me. Thanx for your help.


J said:
Whether you switch between 6 different pages or use a panel control and keep
submitting 1 page in a wizard fashion is entirely up to you, store in your
datasets, store in session or use viewstate the important thing to get is
your validation correct so that it is physically impossible for users to
miss out fields or enter invalid data and then when you come to perform your
update, spawn a transaction and commit if successful else rollback if
failure.
Personally I like the tabbed approach using panels, yes there is a great
deal more going on in the page than anyone looking at it would think but
there is far less processing in the background as everything is still there
for you come the end ready to submit; circumstance, preference and any other
number of factors might sway your decision, one last comment though, I'd
tighten up your validation so that they simply can't submit the form
correctly if they miss critical fields, if it is not going to go into the
database because it is going to fail(rollback) what is the point of allowing
them to submit the form anyway?

regards,
J.
 
J

J

Paste this into a webforms aspx file (WebForm1.aspx);

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="panels.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>WebForm1</TITLE>
<META content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<META content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<META content="JavaScript" name="vs_defaultClientScript">
<META content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<BODY>
<FORM id="Form1" method="post" runat="server">
<TABLE width="300" border="0">
<TR>
<TD>
<ASP:pANEL id="pnlTab1" runat="server" width="250px" height="250px"
backcolor="Green" visible="False">
<ASP:TEXTBOX id="txt1" runat="server"></ASP:TEXTBOX>
<ASP:TEXTBOX id="txt2" runat="server"></ASP:TEXTBOX>
</ASP:pANEL>
<ASP:pANEL id="pnlTab2" runat="server" width="250px" height="250px"
backcolor="Red">
<ASP:TEXTBOX id="txt3" runat="server"></ASP:TEXTBOX>
<ASP:TEXTBOX id="txt4" runat="server"></ASP:TEXTBOX>
</ASP:pANEL>
</TD>
</TR>
<TR>
<TD>
<ASP:BUTTON id="btnSwitch" runat="server" text="Switch"></ASP:BUTTON>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>

and paste this into the code behind aspx.vb file;

Private Sub btnSwitch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSwitch.Click

If (pnlTab1.Visible = True) Then
pnlTab1.Visible = False
pnlTab2.Visible = True
Else
pnlTab1.Visible = True
pnlTab2.Visible = False
End If

End Sub

each panel control contains two text boxes but you could put anything in
them, tables, ddls, datagrids, anything really and you can also have as many
as you want, just initially make only one visible.

You'll notice that only the red panel is visible initially, click the switch
button to move between the red and green panels. Panel controls are rendered
as DIV tags, before asp.net came along you could make these anyway,
understand that you are going to be posting back when switching between
however many panels you need, you'll notice though that values entered
between clicks remain in viewstate so you lose no data. You could write
client side code that could switch between the divs but you'll need to
evaluate your situation re connection speeds, user requirements, etc, etc...
before being forced down that road....

J.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top