Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wizard control 1

Status
Not open for further replies.

adugenet

Technical User
Feb 24, 2007
48
US
I am using a wizard control and I have setps for contact information, comments and summary. I would like to pass the comments to the summary page for the users to see the comments they write and I am wondering how can I pass the comments to the summary page. any help is appreciated.
 
Make the final step in the wizard a summary page and populate the controls on the final wizard step from the controls on the previous wizard steps. Create an event for OnWizardFinish to save the values from the previous steps to the database. here's a quick example
Code:
<asp:Wizard id="MyWizard" runat="server">
  <Steps>
    <asp:WizardStep id="Step1" runat="server" ActiveStepChanged="StepChanged" FinishButtonClick="Finished">
       Name: <asp:TextBox id="nameTextBox" runat="server" />
    </asp:WizardStep>
    <asp:WizardStep id="Step2" runat="server" ...>
       Age: <asp:TextBox id="ageTextBox" runat="server" />
    </asp:WizardStep>
    <asp:WizardStep id="Step3" runat="server" ...>
      Name: <asp:Label id="nameLabel" runat="server" />
      <br />
      Age: <asp:Label id="ageLabel" runat="server" />
    </asp:WizardStep>
  </Steps>
</asp:Wizard>

---code behind---
protected void StepChanged(object sender, WizardStepEventArgs e)
{
   switch(MyWizard.ActiveStepIndex)
   {
      case 0:
         //do nothing step 1
         break;
      case 1:
         //do nothing step 2
         break;
      case 2:
         nameLabel.Text = nameTextBox.Text;
         ageLabel.Text = ageTextBox.Text;
         break;
   }
}
protected void Finished(object sender, WizardNavigationEventHandler e)
{
    string name = nameLabel.Text;
    int age = int.Parse(ageLabel.Text);

    //save name & age to db.
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
thank you for your response....I did look at your tips and I am still having difficulties to pass comments from step 1 to step 2 which is a summary page.attached my aspx page and code behind ...thanks for the help
%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="feedback.aspx.vb" Inherits="feedback" title="Cost Estimating Unit Feedback Form" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<%-- <script type="text/javascript" language="javascript">
Function ValidateComments(sender, args)
{
if (args.Value.length > 50
args.IsValid = false;
else
args.IsValid = true;
}
</script>--%>


<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="2" BackColor="#F7F6F3" BorderColor="#CCCCCC" Height="125px" Width="824px">
<StepStyle BorderWidth="0px" ForeColor="#5D7B9D" HorizontalAlign="Left" VerticalAlign="Top" />
<SideBarStyle BackColor="SteelBlue" BorderWidth="0px" Font-Size="0.9em" VerticalAlign="Top"
Width="165px" />
<NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284775" />
<WizardSteps>
<asp:WizardStep runat="server" Title="Contact Information">
<table>
<tr>
<td style="width: 100px; height: 26px;">
Your Name</td>
<td style="width: 74px; height: 26px;">
<asp:TextBox ID="txtName" runat="server" Width="224px"></asp:TextBox>
</td>
<td style="width: 100px; height: 26px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName"
ErrorMessage="Please enter your name">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td style="width: 100px; height: 26px;">
Email</td>
<td style="width: 74px; height: 26px;">
<asp:TextBox ID="txtEmail" runat="server" Width="223px"></asp:TextBox>
</td>
<td style="width: 100px; height: 26px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtEmail"
ErrorMessage="Please enter your email address">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
Display="Dynamic" ErrorMessage="Please enter a valid email address (foo@boo.com)"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td style="width: 100px">
</td>
<td colspan="2">
<asp:ValidationSummary ID="ValidationSummary2" runat="server" Width="301px" />
</td>
</tr>
</table>
</asp:WizardStep>
<asp:WizardStep runat="server" Title="Comments">
<table cellpadding="10">
<tr>
<td style="width: 118px; font-family: Arial; height: 117px;">
<font face="Arial, Helvetica, sans-serif" size="2"><span>
<span style="font-size: 10pt; font-family: Arial;"><b>
<asp:Label ID="Label1" runat="server" Font-Bold="False" Height="38px" Text="I suggest that you include the following information:"
Width="183px"></asp:Label>
</b></span></span></font></td>
<td style="width: 100px; height: 117px;">
<asp:TextBox ID="txtComments" runat="server" Height="89px" TextMode="MultiLine" Width="380px"></asp:TextBox>
</td>
<td style="width: 100px; height: 117px;">
</td>
</tr>
<tr>
<td style="width: 118px; height: 12px">
<span style="font-size: 10pt; font-family: Arial">
<br />
<asp:Label ID="Label2" runat="server" Text="Please make these changes:"></asp:Label>
</span></td>
<td style="width: 100px; height: 12px">
<asp:TextBox ID="txtSuggestions" runat="server" Height="82px" TextMode="MultiLine"
Width="378px"></asp:TextBox>
</td>
<td style="width: 100px; height: 12px">
</td>
</tr>
<tr>
<td style="width: 118px">
</td>
<td style="width: 100px">

</td>
<td style="width: 100px">
</td>
</tr>
</table>
</asp:WizardStep>
<asp:WizardStep runat="server" StepType="Finish" Title="Summary">
Summary of your comments / Suggestions<br />
Name: <asp:Label id="nameLabel" runat="server" />


</asp:WizardStep>

<asp:WizardStep runat="server" StepType="Complete" Title="Complete" >
<table width="100%">
<tr>
<td style="text-align: center" >
<span style="font-size: 10pt; font-family: Arial">
Thank you for taking your time to give us your comments.<br />
We will take aproperiate action after we review your comment<br />
Once again, Thank you very much.<br />
<br />
<br />
<strong><em>
Engineering Cost Data &amp; Estimating Unit<br />
</em></strong>
</span>
</td>
</tr>
</table>
<br />
</asp:WizardStep>
</WizardSteps>
<SideBarButtonStyle BorderWidth="0px" Font-Names="Verdana" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" BorderStyle="Solid" Font-Bold="True" Font-Size="0.9em"
ForeColor="White" HorizontalAlign="Left" />
</asp:Wizard>
</asp:Content>



Imports System.Net.Mail
Partial Class feedback
Inherits System.Web.UI.Page

Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick
SendMail(txtEmail.Text, txtComments.Text)
End Sub
Private Sub SendMail(ByVal from As String, ByVal body As String)
Dim objEmail As New MailMessage
objEmail.To.Add("faddis75@yahoo.com")
objEmail.From = New MailAddress(txtEmail.Text)
Dim sMsg As String
sMsg = "Feedback has been sent to you." & vbCrLf & "The results are as follows:" & vbCrLf
sMsg += "Email Address : " & txtEmail.Text & vbCrLf
sMsg += "Contact Person Name : " & txtName.Text & vbCrLf
sMsg += "Contact Person's Comments : " & txtComments.Text & vbCrLf
sMsg += "Contact Person's Suggestions : " & txtSuggestions.Text & vbCrLf
objEmail.Subject = "You have Feedback"
objEmail.Body = sMsg
objEmail.IsBodyHtml = False
Dim SmtpMail As New SmtpClient()
SmtpMail.Send(objEmail)
End Sub

End Class
 
here are some issues I see:[ol][li]your start on ActiveStepIndex 2 not ActiveStepIndex 0.[/li]
[li]your code behind does not have an event for ActiveStepChanged.[/li]
[li]you pass the email address and body to the SendMail function, but you don't use the arguments, you reference the controls text directly in the function. if that's the case simply do [tt]Private Sub SendMail()... End Sub[/tt]. then from the save event call [tt]Me.SendMail()[/tt].[/li]
[li]you declare a client CustomValidator function, but you don't reference the function in your code.[/li][/ol]
I would also use CSS and/or skin files for HTML formatting to reduce the clutter.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
thank you Jason for your tips and valuable comments ...using your suggestion I am very close to get what I wanted. thanks again and you deserve my star!
 
one more thing folks..how can I notify to the sender that I got their e-mail and If possible I would like send a message....Your e-mail has been recieved and I will look into your comments something like this..

is it something easily done?

Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick
SendMail()
End Sub
Private Sub SendMail()
Dim objEmail As New MailMessage
objEmail.To.Add("Bid.Letting@dot.state.mn.us")
objEmail.From = New MailAddress(txtEmail.Text)
Dim sMsg As String
sMsg = "Feedback has been sent to you." & vbCrLf & "The results are as follows:" & vbCrLf
sMsg += "Email Address : " & txtEmail.Text & vbCrLf
sMsg += "Contact Person Name : " & txtName.Text & vbCrLf
sMsg += "Contact Person's Comments : " & txtSummary.Text & vbCrLf
sMsg += "Contact Person's Suggestions : " & txtSuggestions.Text & vbCrLf
objEmail.Subject = "You have Feedback"
objEmail.Body = sMsg
objEmail.IsBodyHtml = False
Dim SmtpMail As New SmtpClient()
SmtpMail.Send(objEmail)
End Sub
 
there is no way from SmtpMail.Send() to know if you actaully receive the message. There are a series of exceptions that can occur which lets the user know the message wasn't sent. But no easy way of stating you did get the message.

You could send a second email to the user so both you and the visitor get an email confirming it was sent.

You could log the message to a database and send the user a response saying the comment is in a que wanting to be received. then have a form where you could download results. as a result is downloaded an email could be sent to the visitor stating the message is out of que and has been read/downloaded/processed.

you may also want to generate a random string of alphanumerics as an ID tracker so you have some unique identifier for the comment.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
thank you Jason for your help. I really appreicate that. you said I could send a second email to the user so both you and the visitor get an email confirming it was sent.
How can I do this?
 
Code:
Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick
        ''send message from visitor to you
        SendMail("Bid.Letting@dot.state.mn.us", txtEmail.Text)
        ''send message from you to visitor
        SendMail(txtEmail.Text, "Bid.Letting@dot.state.mn.us")
End Sub
Private Sub SendMail(ByVal toEmail as string, ByVal fromEmail as string)
        Dim objEmail As New MailMessage
        objEmail.To.Add(toEmail)
        objEmail.From = New MailAddress(fromEmail)
        Dim sMsg As String
        sMsg = "Feedback has been sent to you." & vbCrLf & "The results are as follows:" & vbCrLf
        sMsg += "Email Address : " & txtEmail.Text & vbCrLf
        sMsg += "Contact Person Name : " & txtName.Text & vbCrLf
        sMsg += "Contact Person's Comments : " & txtSummary.Text & vbCrLf
        sMsg += "Contact Person's Suggestions : " & txtSuggestions.Text & vbCrLf
        objEmail.Subject = "You have Feedback"
        objEmail.Body = sMsg
        objEmail.IsBodyHtml = False
        Dim SmtpMail As New SmtpClient()
        SmtpMail.Send(objEmail)
End Sub

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
wow you already made my day.You so awsome and thank you for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top