p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other programmers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 14th, 2009, 05:38 PM
Fed Fed is offline
Authorized User
Points: 157, Level: 3
Points: 157, Level: 3 Points: 157, Level: 3 Points: 157, Level: 3
Activity: 23%
Activity: 23% Activity: 23% Activity: 23%
 
Join Date: Oct 2009
Posts: 40
Thanks: 19
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old October 14th, 2009, 06:01 PM
Imar's Avatar
Wrox Author
Points: 35,654, Level: 82
Points: 35,654, Level: 82 Points: 35,654, Level: 82 Points: 35,654, Level: 82
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,575
Thanks: 12
Thanked 284 Times in 280 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

Everyone is unique, except for me.
Author of Beginning ASP.NET 4 : in C# and VB, Beginning ASP.NET 3.5 : in C# and VB and ASP.NET 2.0 Instant Results.

Did this post help you? Click the button to show your appreciation!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old October 14th, 2009, 06:56 PM
Fed Fed is offline
Authorized User
Points: 157, Level: 3
Points: 157, Level: 3 Points: 157, Level: 3 Points: 157, Level: 3
Activity: 23%
Activity: 23% Activity: 23% Activity: 23%
 
Join Date: Oct 2009
Posts: 40
Thanks: 19
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>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old October 15th, 2009, 03:45 AM
Imar's Avatar
Wrox Author
Points: 35,654, Level: 82
Points: 35,654, Level: 82 Points: 35,654, Level: 82 Points: 35,654, Level: 82
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,575
Thanks: 12
Thanked 284 Times in 280 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

Everyone is unique, except for me.
Author of Beginning ASP.NET 4 : in C# and VB, Beginning ASP.NET 3.5 : in C# and VB and ASP.NET 2.0 Instant Results.

Did this post help you? Click the button to show your appreciation!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
Fed (October 15th, 2009)
  #5 (permalink)  
Old October 15th, 2009, 11:52 AM
Fed Fed is offline
Authorized User
Points: 157, Level: 3
Points: 157, Level: 3 Points: 157, Level: 3 Points: 157, Level: 3
Activity: 23%
Activity: 23% Activity: 23% Activity: 23%
 
Join Date: Oct 2009
Posts: 40
Thanks: 19
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...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old October 15th, 2009, 12:02 PM
Imar's Avatar
Wrox Author
Points: 35,654, Level: 82
Points: 35,654, Level: 82 Points: 35,654, Level: 82 Points: 35,654, Level: 82
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,575
Thanks: 12
Thanked 284 Times in 280 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

Everyone is unique, except for me.
Author of Beginning ASP.NET 4 : in C# and VB, Beginning ASP.NET 3.5 : in C# and VB and ASP.NET 2.0 Instant Results.

Did this post help you? Click the button to show your appreciation!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old October 15th, 2009, 02:38 PM
Fed Fed is offline
Authorized User
Points: 157, Level: 3
Points: 157, Level: 3 Points: 157, Level: 3 Points: 157, Level: 3
Activity: 23%
Activity: 23% Activity: 23% Activity: 23%
 
Join Date: Oct 2009
Posts: 40
Thanks: 19
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #8 (permalink)  
Old October 16th, 2009, 02:34 PM
Imar's Avatar
Wrox Author
Points: 35,654, Level: 82
Points: 35,654, Level: 82 Points: 35,654, Level: 82 Points: 35,654, Level: 82
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,575
Thanks: 12
Thanked 284 Times in 280 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

Everyone is unique, except for me.
Author of Beginning ASP.NET 4 : in C# and VB, Beginning ASP.NET 3.5 : in C# and VB and ASP.NET 2.0 Instant Results.

Did this post help you? Click the button to show your appreciation!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #9 (permalink)  
Old October 22nd, 2009, 04:28 PM
Fed Fed is offline
Authorized User
Points: 157, Level: 3
Points: 157, Level: 3 Points: 157, Level: 3 Points: 157, Level: 3
Activity: 23%
Activity: 23% Activity: 23% Activity: 23%
 
Join Date: Oct 2009
Posts: 40
Thanks: 19
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #10 (permalink)  
Old October 22nd, 2009, 06:32 PM
Imar's Avatar
Wrox Author
Points: 35,654, Level: 82
Points: 35,654, Level: 82 Points: 35,654, Level: 82 Points: 35,654, Level: 82
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,575
Thanks: 12
Thanked 284 Times in 280 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

Everyone is unique, except for me.
Author of Beginning ASP.NET 4 : in C# and VB, Beginning ASP.NET 3.5 : in C# and VB and ASP.NET 2.0 Instant Results.

Did this post help you? Click the button to show your appreciation!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 01: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 04: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 10:09 AM



All times are GMT -4. The time now is 12:10 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© 2010 Wiley Publishing, Inc