user: psw:
| lost password
ASP.NET 3.5 For Dummies :: Forums
Home » Recent messages recent posts - RSS
1/15/2010 5:49:03 AM
topic: Chapter 5: CheckBox and CheckBoxList Controls

thered
Posts 1
Hello, Ken

Some errors ocurred in the script of this part in chapter 5.
First, in the following script (in bold):

If Not IsPostBack Then
Dim arrlGames As New ArrayList
arrlGames.Add("Scrabble")
arrlGames.Add("Crosswords")
arrlGames.Add("Wonderwords")
arrlGames.Add("Sudoku")
arrlGames.Sort()
CheckBoxList!.DataSource = arrlGames
CheckBoxList!.DataBind()
End If

I think the correct script is:

If Not IsPostBack Then
Dim arrlGames As New ArrayList
arrlGames.Add("Scrabble")
arrlGames.Add("Crosswords")
arrlGames.Add("Wonderwords")
arrlGames.Add("Sudoku")
arrlGames.Sort()
CheckBoxList1.DataSource = arrlGames
CheckBoxList1.DataBind()
End If

Also, a script error was found in the script of the button.

Dim strSel As String = " "
For Each chbx As ListItem In CheckBoxList1.Items
If chbx.Selected Then
strSel = srtSel & chbx.Text & "<br/>"
End If
Next
Label1.Text = strSel

According to the program, the error is in the 4th line: strSel = srtSel & chbx.Text & "<br/>", concerning about the srtSel. The message in visual basic is that wam not declared.

Could you check, please what is going on?

My book version is the Portuguese Version. The scripts I mentioned are on page 68.

Thanks

Christian
edited by thered on 1/15/2010
12/22/2009 1:21:20 PM
topic: Page 119 - C# Code May Need an Imports Directive

Ken Cox
Posts 170
Depending on the type of project you used to create the Web, Visual Studio may not include all the references that you require for the C# version of the code on Page 119. The symptom is the following error message:

CS1935: Could not find an implementation of the query pattern for source type 'System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement>'. 'Where' not found. Are you missing a reference to 'System.Core.dll' or a using directive for 'System.Linq'?

The fix is to add the following reference at the top of the page:

<%@ Import Namespace="System.Linq" %>

An alternate fix is to ensure that the web.config file references all of the namespaces by including this in the <system.web> section:

<pages>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Generic"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Linq"/>
<add namespace="System.Xml.Linq"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>

Ken
12/3/2009 10:11:30 PM
topic: Page 58 about insertion at <script> and </script>

paddyinuae
Posts 2
Hi Ken,

Thanks for the amazingly prompt reply - you should do this as a business :-)!

All fixed - it works like a charm.
I probably would never have figured out the syntax to that import statement.

Thanks very much for the help, and great book btw.
It's made all the better for the eratta (minor though it is), download chapter code, and this forum.
Well done, and thanks again.

Ian.
12/3/2009 12:05:24 PM
topic: Page 58 about insertion at <script> and </script>

Ken Cox
Posts 170
paddyinuae wrote:
I've tried all sorts of techniques and I've pasted that import directive just about everywhere, but still can't get the examples to work with code behind.


Hi Ian,

Could you post the code that's not working?

In the codebehind, you use the Imports statement with a different syntax:

Imports System.Linq

Partial Class linqtest
Inherits System.Web.UI.Page
Protected Sub Page_Load _
(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Me.Load
Dim q = From f In System.Drawing.FontFamily.Families
For Each fnt In q
Response.Write(fnt.Name & "<br />")
Next
End Sub
End Class

Does the preceding work for you?

Ken
12/3/2009 8:54:33 AM
topic: Page 58 about insertion at <script> and </script>

paddyinuae
Posts 2
Greetings.

I've looked through the FAQs, and I apologize in advance if this is a dumb question. As it's to do with LINQ and code behind files, I though here would be an opportune place to raise the question.

I notice that all examples use the "single page model" of coding. I've successfully followed the examples in the book, but would like to use the ""code behind model" of coding. I've tried all sorts of techniques and I've pasted that import directive just about everywhere, but still can't get the examples to work with code behind.

Can it be done, and if so, how difficult is it?

Thanks in anticipation.

Ian.
11/19/2009 4:00:30 PM
topic: Page 171 - Repeated Instruction

Ken Cox
Posts 170
Step 6 on Page 171 should be deleted as it duplicates Step 4 on Page 170.
11/19/2009 9:13:25 AM
topic: c# chapter 13, no databases in app_data folder

jason palmer
Posts 9
Ken,

Think I saw this much earlier in the examples as well, will let you know when I find problems, they all very minor so can see how they slipped in.

regards

JP
11/19/2009 8:50:49 AM
topic: chapter 11, install small business starter kit

jason palmer
Posts 9
I was a bit confused about how to get the kit working, this made it clearer

http://forums.asp.net/t/1484972.aspx

"I am using Visual Web Developer 2008 Express also and downloaded the Small Business Starter kit.

I double clicked the SmallBusiness.vsi file and it ran the install.

Next, opened Visual Web Developer.

On the Start Page selected Create Web Site.

On the Create Web Site box that opens you will see Templates at the bottom.

If installed correctly, you will see SmallBusiness as an option.

Selected it and since we are using VWD2008/ASP.NET 3.5 it will ask to convert the template from 2.0 to 3.5, select yes.

It then opens the entire "project".

There are directions on how to use it, once it is opened.




Already started modifying it, works great."
11/19/2009 5:44:19 AM
topic: chapter 10, c# example problems

jason palmer
Posts 9
default.aspx complained about not having a sqldatasource1 and the App_Data folder is missing a database, I copied the one over from chapter 6 and put a sqldatasource on the form, but, for those new to programming,this could be scary
11/19/2009 5:26:40 AM
topic: chapter 9 , c# examples problems

jason palmer
Posts 9
Ken,

checkcolour.aspx not working

but

rgbservice.asmx is

so not sure of the cause, if I do checkcolour with debug i get

The request failed with HTTP status 404: Not Found.
pages: 1 2

Home » Recent messages