Advertisement

03.28.2008 at 05:51PM PDT, ID: 23278888
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.9

Validation of textbox entries and how to disable "Tabbing"

Asked by dmasini in Active Server Pages (ASP)

Tags: ,

Experts,

Newbie here so I will try to explain the issue as well as possible.  So I have this page where (thanks to the_bachelor) that we pass params for a record number which I will eventually send out as an HTML-formatted e-mail vias aspNetMail (nice product by the way!).

Now I want make sure that I get the following:

1) In TextBox1 I want a valid e-mail (for now only has to be formatted properly...name@domain.TLD)
2) In TextBox2 I want a valid qty they want to order
3) In TextBox3 I want a valid date they need the product

Just FYI...I know how to apply "RequiredFieldValidators", "RegularExpressionValidators" and "RangeValidators" and "ValidatorCalloutExtenders" etc.

The problem is when I run my page I am able to just "TAB" through the fields even though I "SetFocusOnError".  I want to ALWAYS force the cursor back to the focused texbox if it DOES not validate properly.

Any ideas/thoughts would be appreciated!  Code Snippet included for your review.

Thanks again,

DM
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
<%@ Page Language="VB" %>
 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
 
<script runat="server">
 
    Dim DoEmailSend As Boolean = False
    Dim RecordID2 As Int32
 
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
 
        DoEmailSend = True
        
    End Sub
    
    Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
 
        'create a new HtmlTextWriter so we can get at the page's source
        Dim stringWriter As New IO.StringWriter()
        Dim htmlWriter As New HtmlTextWriter(stringWriter)
  
        'render the page
        MyBase.Render(htmlWriter)
 
        'get the html source of the current page
        Dim html As String = stringWriter.ToString()
 
        If DoEmailSend Then
            'send it as an email
            SendEmail(html)
        End If
   
        'send to the browser
        writer.Write(html)
    End Sub 'Render
 
    Sub SendEmail(ByVal html As String)
        'create an email object, and set the mail server = "mail.mycompany.com"
        Dim msg As aspNetEmail.EmailMessage = New aspNetEmail.EmailMessage("win2003.guicorporation.com")
        
        
        'set recipient error logging off
        msg.IgnoreRecipientErrors = True
        
        'set exception throwing off
        msg.ThrowException = False
 
        '****************************************************************
        '*** These lines removed to address issue with stripping off pulldowns when sending 
        '*** HTML pages via e-mail.  Replaced with new dll 3.6.0.12
        '*** msg.Body = html
        '*** since we are loading a html page, set the bodyformat
        '*** msg.BodyFormat = aspNetEmail.MailFormat.Html
        '****************************************************************
        
        'set logging on
        msg.Logging = True
        msg.LogPath = "c:\aspNetMail-Logs\aspnetmail.log"
        
        msg.WriteLineToLog("======= START RAW HTML =======")
        msg.WriteLineToLog(html)
        msg.WriteLineToLog("======= END RAW HTML =======")
        
        
        Dim hu As New aspNetEmail.HtmlUtility(msg)
        hu.LoadString(html, Nothing)
        hu.HtmlRemovalOptions = hu.HtmlRemovalOptions Or aspNetEmail.HtmlRemovalOptions.EventArgument Or aspNetEmail.HtmlRemovalOptions.InputHiddenTag Or aspNetEmail.HtmlRemovalOptions.InputSubmitTag Or aspNetEmail.HtmlRemovalOptions.ReplaceSelectTagWithSelectedText Or aspNetEmail.HtmlRemovalOptions.ReplaceInputTextAreaWithValue
 
        hu.Render()
 
        msg = hu.ToEmailMessage()
        
        'set the from address
        msg.FromAddress = TextBox1.Text
        
 
        'set the to address
        msg.To = "dmasini@guicorporation.com"
        
        
        'set the Misc Comment line
        msg.Subject = TextBox3.Text
        
 
        'set the content encoding
        msg.ContentTransferEncoding = aspNetEmail.MailEncoding.QuotedPrintable
        
 
        'send the email
        msg.Send()
 
    End Sub
     
</script>
    
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Request a Quote via E-Mail</title>
    </head>
<body>
    <form id="form1" runat="server">
 
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <br />
        <table style="width: 564px; border-left-color: silver; border-bottom-color: silver; border-top-style: ridge; border-top-color: silver; border-right-style: ridge; border-left-style: ridge; border-right-color: silver; border-bottom-style: ridge;">
            <tr>
                <td style="height: 381px; width: 314px;">
                    <table id="TABLE1" style="width: 528px" language="javascript" onclick="return TABLE1_onclick()">
                        <tr>
                            <td bgcolor="maroon" style="height: 24px" colspan="2">
                            <asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Names="Verdana"
            Font-Size="Small" ForeColor="DarkBlue" Text="Quote Form..." style="font-weight: bold; font-size: 10pt; color: white; font-family: verdana"></asp:Label></td>
                        </tr>
                        <tr>
                            <td colspan="2" style="border-left-color: navy; border-bottom-color: navy; border-top-style: solid;
                                border-top-color: navy; border-right-style: solid; border-left-style: solid;
                                height: 29px; border-right-color: navy; border-bottom-style: solid">
                                <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Verdana" ForeColor="Navy"
                                    Style="text-align: center" Text="(Please provide a quote for the following item...)" Font-Size="Medium"></asp:Label></td>
                        </tr>
                        <tr>
                            <td style="height: 25px; width: 489px; text-align: right; background-color: gray;">
                                <strong style="border-top-width: thin; font-weight: bold; border-left-width: thin; border-left-color: gray; border-bottom-width: thin; border-bottom-color: gray; color: white; border-top-color: gray; border-right-width: thin; border-right-color: gray"> Your E-Mail:</strong></td>
                            <td style="width: 285055px; height: 25px">
                                &nbsp;<asp:TextBox ID="TextBox1" runat="server" Width="252px" Height="40px" CausesValidation="True" AutoCompleteType="Email" Wrap="False">enter your e-mail address here</asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
                                    ErrorMessage="(cannot be blank)" Height="24px" SetFocusOnError="True" Style="position: absolute"></asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1"
                                    ErrorMessage="(valid e-mail format required)" SetFocusOnError="True" Style="left: 340px;
                                    position: absolute; top: 136px" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                    Width="200px"></asp:RegularExpressionValidator>
                            </td>
                        </tr>
                        <tr>
                            <td style="height: 24px; text-align: right; font-weight: bold; color: white; background-color: gray;">
                                <strong> To:</strong></td>
                            <td style="width: 285055px; height: 24px; font-weight: bold; font-size: 12pt; color: black; font-family: Arial;">
                                sales@hpoll.com</td>
                        </tr>
                        <tr>
                            <td style="height: 24px; text-align: right; font-weight: bold; color: white; background-color: gray;">
                                <strong>Subject:</strong></td>
                            <td style="width: 285055px; height: 24px; font-weight: bold; font-size: 12pt; font-family: Arial;">
                                Please provide a quote for the following item...</td>
                        </tr>
                        <tr>
                            <td style="font-weight: bold; height: 20px; text-align: right; border-top-width: thin; border-left-width: thin; border-left-color: blue; border-bottom-width: thin; border-bottom-color: blue; vertical-align: top; color: white; border-top-color: blue; background-color: gray; border-right-width: thin; border-right-color: blue;">
                                Note:</td>
                            <td style="width: 285055px; height: 20px">
                                <asp:TextBox ID="TextBox3" runat="server" Height="56px" Width="256px" ToolTip="Enter any misc notes here..." style="cursor: text"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td bgcolor="maroon" style="height: 24px" colspan="2">
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" style="height: 24px">
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                    <asp:Label ID="Label3" runat="server" Text="QUANTITY REQUIRED:" Width="204px" style="text-align: right" BackColor="#FFFFC0" Font-Bold="True" Font-Size="Medium"></asp:Label>
                    <asp:TextBox ID="TextBox2" runat="server" Width="96px"></asp:TextBox>
                    <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="TextBox2"
                        ErrorMessage="(Minimum 1 - Maximum 999999)" MaximumValue="999999" MinimumValue="1"
                        SetFocusOnError="True" Style="position: absolute"></asp:RangeValidator>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox1"
                        ErrorMessage="(qty must be 1 or greater)" InitialValue="0" SetFocusOnError="True"
                        Style="position: absolute"></asp:RequiredFieldValidator>
                    <br />
                    <asp:Label ID="Label4" runat="server" BackColor="#FFFFC0" Font-Bold="True" Font-Size="Medium"
                        Style="text-align: right" Text="DATE REQUIRED:" Width="204px"></asp:Label>
                    <asp:TextBox ID="TextBox4" runat="server" CausesValidation="True" ToolTip="Click here to select a date required..."
                        Width="96px"></asp:TextBox>
                    <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox4">
                    </cc1:CalendarExtender>
                    <br />
                    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
                        DataSourceID="SqlDataSource2" Height="136px" Width="532px">
                        <Fields>
                            <asp:BoundField DataField="RecordID" HeaderText="RecordID:" InsertVisible="False"
                                SortExpression="RecordID">
                                <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Right" Width="200px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="CTMFGNAME" HeaderText="Vendor:" SortExpression="CTMFGNAME">
                                <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Right" Width="200px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="CTCATALOG" HeaderText="Catalog:" SortExpression="CTCATALOG">
                                <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Right" Width="200px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="CTDESCRIPTION" HeaderText="Description:" SortExpression="CTDESCRIPTION">
                                <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Right" Width="200px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="DISTSKU" HeaderText="NAED V/I:" SortExpression="DISTSKU">
                                <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Right" Width="200px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="COMMODITYNAME" HeaderText="Category:" SortExpression="COMMODITYNAME">
                                <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Right" Width="200px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="CTUM" HeaderText="Sold By:" SortExpression="CTUM">
                                <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Right" Width="200px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="ShippedQtyPAM" HeaderText="Qty in Stock:" SortExpression="ShippedQtyPAM">
                                <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Right" Width="200px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="CurrSellPricePAM" DataFormatString="{0:c}" HeaderText="List Price:"
                                HtmlEncode="False" SortExpression="CurrSellPricePAM">
                                <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Right" />
                            </asp:BoundField>
                        </Fields>
                        <HeaderStyle BackColor="#FFFFC0" HorizontalAlign="Right" VerticalAlign="Top" />
                        <PagerSettings Position="Top" />
                        <RowStyle BackColor="#FFFBD6" />
                        <FieldHeaderStyle BackColor="#FFFF99" ForeColor="#404040" />
                        <AlternatingRowStyle BackColor="White" />
                    </asp:DetailsView>
                    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Send..." style="width: 200px; cursor: hand;" OnClientClick='alert("Page Captured.  Click OK to Send!")' />
                                <asp:Button ID="Button2" runat="server" OnClientClick="window.close()" Style="width: 200px; cursor: hand;"
                                    Text="Close this Window..." /><br />
                    <asp:Panel ID="Panel1" runat="server" Height="50px" Style="width: 500px; font-weight: bold; font-size: 8pt; color: silver; font-family: verdana; height: 200px;" Width="125px">
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;
                        &nbsp; &nbsp; &nbsp;&nbsp;
                        <br />
                        <br />
                        (To prevent Spam the originating IP Address was:
                        <%=Request.ServerVariables("REMOTE_ADDR")%>)
                        <br />
                        <br />
                        &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
                        ********************** ** LEGAL DISCLAIMER ************************
                        <br />
                        This E-mail message and any attachments may contain legally privileged, confidential
                        or proprietary information. If you are not the intended recipient(s), or the employee
                        or agent responsible for delivery of this message to the intended recipient(s),
                        you are hereby notified that any dissemination, distribution or copying of this
                        E-mail message is strictly prohibited. If you have received this message in error,
                        please immediately notify the sender and delete this E-mail message from your computer.<br />
                    </asp:Panel>
                </td>
            </tr>
        </table>
        <br />
        &nbsp;<br />
                    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:IDC_Receiving %>"
                          
                        SelectCommand="SELECT [CTMFGNAME], [CTDESCRIPTION], [DISTSKU], [CTUM], [COMMODITYNAME], [RecordID], [CTCATALOG], [IDCPROPPRICE], [ShippedQtyPAM], [CurrSellPricePAM] FROM [Cooper-Master-Items-Table] WHERE (([IDCPROVIDERCODE] = @IDCPROVIDERCODE) AND ([RecordID] = @RecordID2))">
                        <SelectParameters>
                            <asp:Parameter DefaultValue="IDC001" Name="IDCPROVIDERCODE" Type="String" />
                            <asp:QueryStringParameter Name="RecordID2" QueryStringField="RecordID2" Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>
        &nbsp;<br />
        &nbsp;<br />
        <br />
        <br />
        <br />
        <br />
    
    </div>
    </form>
</body>
</html>
[+][-]03.29.2008 at 03:43AM PDT, ID: 21236110

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.30.2008 at 08:35AM PDT, ID: 21241002

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.31.2008 at 12:09AM PDT, ID: 21243619

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Active Server Pages (ASP)
Tags: Microsoft, Visual Web Developer 2005
Sign Up Now!
Solution Provided By: sybe
Participating Experts: 1
Solution Grade: A
 
 
[+][-]03.31.2008 at 06:06PM PDT, ID: 21250506

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628