Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 14th, 2009, 04:38 PM
Fed Fed is offline
Authorized User
 
Join Date: Oct 2009
Posts: 55
Thanks: 26
Thanked 0 Times in 0 Posts
Default Chapter 9 ContactForm.ascx

Hi everybody, this is my first posting and here goes;

Using Microsoft Visual Web Studio 2008 V. 9.0.30729.1 & .NET Framework V. 3.5 SP1 A funny thing happened with ContactForm.ascx at the end of chapter 9, the design view is blank but it still works when I invoke the page with CTRL F5. I even tried copying the code back into the design view and the first time it showed the design portion but when I invoked it doubled up the page content and subsequently the pasted design also disappeared leading me to believe that the design is there but just invisible and only on that form any ideas? I am also getting a warning message on the same form for the <div class="PleaseWait"> says class not defined but the image works fine in the webpage. Last but not least, the errors do not appear all at once like in the book samples, I can only get the phone number error to appear after I fill out all the other fields, why is that?

Thanks,

Fed
 
Old October 14th, 2009, 05:01 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi fed,

The Design View issue is a bug in VWD 2008: Chapter 10 - Ajax try it out

Do you have the same issue with the validators on the live site at www.planetwrox.com?

If not, can you post your code?

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old October 14th, 2009, 05:56 PM
Fed Fed is offline
Authorized User
 
Join Date: Oct 2009
Posts: 55
Thanks: 26
Thanked 0 Times in 0 Posts
Default

Imar thanks for getting back so fast :). I will follow up on the first issue but I tested the PlanetWrox and that works fine so I'm going to post the code.

Thanks

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContactForm.ascx.cs" Inherits="Controls_ContactForm" Debug="false" %>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
font-size: x-large;
font-weight: bold;
}
</style>

<script type="text/javascript">
function ValidatePhoneNumbers(source, args)
{
var txtPhoneHome = document.getElementById('<%= txtPhoneHome.ClientID %>');
var txtPhoneBusiness = document.getElementById('<%= txtPhoneBusiness.ClientID %>');
if (txtPhoneHome.Value != '' || txtPhoneBusiness.value != '')
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
</script>

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate>
<table class="style1" runat="server" id="FormTable">
<tr>
<td colspan="3">
<span class="style2">Get in touch with us</span><br />
<br />
Use the form below to get in touch with us. Enter your name, e-mail address and
your home or business phone number to get in touch with us.</td>
</tr>
<tr>
<td>
Your name</td>
<td>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtName" ErrorMessage="Please enter your name">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Your e-mail addres</td>
<td>
<asp:TextBox ID="txtEmailAddress" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtEmailAddress" Display="Dynamic"
ErrorMessage="Please enter an e-mail address">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtEmailAddress" Display="Dynamic"
ErrorMessage="Please enter a valid e-mail address"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
Your e-mail address again</td>
<td>
<asp:TextBox ID="txtEmailAddressConfirm" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtEmailAddressConfirm" Display="Dynamic"
ErrorMessage="Please confirm the e-mail address">*</asp:RequiredFieldValidator>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="txtEmailAddress" ControlToValidate="txtEmailAddressConfirm"
Display="Dynamic" ErrorMessage="Please re-type the e-mail address">*</asp:CompareValidator>
</td>
</tr>
<tr>
<td>
Home phone number</td>
<td>
<asp:TextBox ID="txtPhoneHome" runat="server"></asp:TextBox>
</td>
<td>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="ValidatePhoneNumbers" Display="Dynamic"
ErrorMessage="Please enter your home or business phone number"
onservervalidate="CustomValidator1_ServerValidate" >*</asp:CustomValidator>
</td>
</tr>
<tr>
<td>
Business phone number</td>
<td>
<asp:TextBox ID="txtPhoneBusiness" runat="server"></asp:TextBox>
</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
Comments</td>
<td>
<asp:TextBox ID="txtComments" runat="server" Height="53px" TextMode="MultiLine"
Width="395px"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtComments" Display="Dynamic"
ErrorMessage="Please enter a comment">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
<asp:Button ID="btnSend" runat="server" Text="Send" onclick="btnSend_Click" />
</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td colspan="3">
<asp:ValidationSummary ID="ValidationSummary1" runat="server"

HeaderText="Please correct the following errors before you press the send button" />
</td>
</tr>
</table>

<asp:Label ID="lblMessage" runat="server" Text="Message Sent" Visible="false"></asp:Label>

</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<div class="PleaseWait">
Please Wait...
</div>
</ProgressTemplate>
</asp:UpdateProgress>
 
Old October 15th, 2009, 02:45 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Fed,

Take a look at this:

if (txtPhoneHome.Value != '' || txtPhoneBusiness.value != '')

You have the first Value with a capital V. This means the client side function doesn't work correctly. Then the page posts back to the server where the server side validation eventually makes sure one of the numbers is fill in. Since the server side validation only runs after the postback, it fires much later than then client side validators...

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
Fed (October 15th, 2009)
 
Old October 15th, 2009, 10:52 AM
Fed Fed is offline
Authorized User
 
Join Date: Oct 2009
Posts: 55
Thanks: 26
Thanked 0 Times in 0 Posts
Default

LOL!!! It worked!! Amazing what a second pair of eyes can do... Also very revealing as I am taking a college course in Web Development that uses your book and when I asked the teacher for help she claimed it was because the logic was out of whack and that's why the phone msg error only appeared at the end. Oh well, live and learn... Thank you, thank you very much, Elvis has left the code...
 
Old October 15th, 2009, 11:02 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Nope, the logic is in order.

If you want, tell your teacher she can contact me if she needs more help with this. Always nice to see when my book is used in a college course....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old October 15th, 2009, 01:38 PM
Fed Fed is offline
Authorized User
 
Join Date: Oct 2009
Posts: 55
Thanks: 26
Thanked 0 Times in 0 Posts
Default

Ok I will do that. On another note the work around in MSDN for the invisible design view did not work for me. Nor did I understand what Veganman did regarding the css.

Have you tried applying the work around to your version of code?

And to top it all off in Chapter 12 last exercise I am getting an error on the last step that should be bringing up the details view in the addeditreview page, it states: "Input string was not in a correct format." and goes on to say;

"An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code."

Unfortunately the the stack trace might as well be written in chinese. Where can I get help on how to interpret the stack trace?

Thanks,

Fed
 
Old October 16th, 2009, 01:34 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
Have you tried applying the work around to your version of code?
Yep, worked fine for me.

Quote:
Unfortunately the the stack trace might as well be written in chinese. Where can I get help on how to interpret the stack trace?
Sometimes the stack trace is useful, sometimes it isn't. Especially when a lot of internal code is involved it isn't too useful. However, when your own code is involved, it shows you exactly where the error occured, and what code called what other code.

If you post it here, we can take a look and try to translate some of that Chinese into plain English.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old October 22nd, 2009, 03:28 PM
Fed Fed is offline
Authorized User
 
Join Date: Oct 2009
Posts: 55
Thanks: 26
Thanked 0 Times in 0 Posts
Default

Ok for some reason it is now working as far as showing the content in the design view, go figure...

Here is the error message re. last exercise in chap. 12, if you could shed some light on the "chinese" please?

Server Error in '/Site' Application.
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7469351
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
System.String.System.IConvertible.ToInt32(IFormatP rovider provider) +46
System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +297
System.Web.UI.WebControls.Parameter.GetValue(Objec t value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +141
System.Web.UI.WebControls.Parameter.GetValue(Objec t value, Boolean ignoreNullableTypeChanges) +63
System.Web.UI.WebControls.ParameterCollection.GetV alues(HttpContext context, Control control) +301
System.Web.UI.WebControls.SqlDataSourceView.Initia lizeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList) +264
System.Web.UI.WebControls.SqlDataSourceView.Execut eSelect(DataSourceSelectArguments arguments) +472
System.Web.UI.DataSourceView.Select(DataSourceSele ctArguments arguments, DataSourceViewSelectCallback callback) +19
System.Web.UI.WebControls.DataBoundControl.Perform Select() +142
System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind() +73
System.Web.UI.WebControls.DetailsView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.Ens ureDataBound() +82
System.Web.UI.WebControls.DetailsView.EnsureDataBo und() +184
System.Web.UI.WebControls.CompositeDataBoundContro l.CreateChildControls() +72
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +44
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842


Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.4028
 
Old October 22nd, 2009, 05:32 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

It's chinese for me as well, wiithout surrounding code ;-)

It looks like it's not accepting your input. You get errors like this when you try to convert a non-number to a number. E.g. Considering a text box with a Text property of "SomeValue", the following code will result in similar errors:

int someInt = Convert.ToInt32(TextBox1.Text);

Do you see code like this, or can you relate it to internal code that would cause this kind of conversion failures?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending mail from ContactForm: how to include a file? vilcene BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 4 September 23rd, 2009 12:18 PM
Registering ASCX gbrown ASP.NET 1.0 and 1.1 Professional 1 January 9th, 2007 11:57 AM
ascx !?! g2000 ASP.NET 2.0 Basics 1 October 21st, 2005 03:33 PM
ascx with javaScript ajindal General .NET 3 January 21st, 2005 08:31 AM
Cannot Load ASCX files mattshea50 ASP.NET 1.x and 2.0 Application Design 1 July 7th, 2004 09:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.