Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers 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 developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 22nd, 2007, 02:08 PM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default Wrox CMS in C#

Hi
I have made an attempt of converting the CMS application to C# using the converter at http://www.dotnettaxi.com/Tools/Converter.aspx. I converted the entire CMS app by removing Handles Me.Load from the page load events where errors occured during convertion. I then corrected various mistakes the converter had made when converting the syntax (mainly to do with accessing the connection string from the web.config).

But.. :( Visual Studio 2005 still lists 8 errors when I try to run the app. The most common error is 'System.Web.UI.HtmlControls.HtmlControl.Attributes ' is a 'property' but is used like a 'method' being an ASP.NET 2.0 and C# novice I cant find a solution to this. An annoying feature of the code converter is that it removes all the code comments which I find a great help. I chose C# as I found it similar to Actionscript which was my only previous experience in OOP. The files can be downloaded from http://www.gkadata.com/files/CmsC.rar

Any help would be greatly appreciated!!

Great book by the way!! If only all .NET books could be based on real world solutions!
  #2 (permalink)  
Old February 22nd, 2007, 04:59 PM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,044
Thanks: 80
Thanked 1,580 Times in 1,557 Posts
Default

Hi there,

Really glad you like the book. Spread the word!! Spread the word....

Anyway, errors like this:
Quote:
quote:.Web.UI.HtmlControls.HtmlControl.Attributes' is a 'property' but is used like a 'method'
usually indicate a problem with arrays / collections. When you convert code like this:

SomeCollection.Items(0)

the converter thinks Items is a method that gets 0 as an argument. Instead, you want to index the array or collection using C# indexers:

SomeCollection.Items[0]

I may be able to give you better help / fixes if you post the problematic lines of code; I didn't have the time to look into the download yet.

Also, when you're with the conversion, please let me know. I'll ask Wrox to make your post with the final code a sticky one, so others can find it more easily.

It's great you're converting it to C#!!

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #3 (permalink)  
Old February 22nd, 2007, 05:13 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I think you will find that this compiles without error in VWD.

www.cssbh.org/dparsons/cms.rar

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
  #4 (permalink)  
Old February 22nd, 2007, 05:16 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Oh forgot to mention the fix, lol. Imar was completely correct in regards to Braces [] vs Parens () and there were about 15 types of these errors througout your code.

Also, in C# you concatanate strings with + as opposed to & you had about 13 instances of this problem. I did not test the site, just got it to compile then zipped it back up. Hope it works out for you.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
  #5 (permalink)  
Old February 22nd, 2007, 05:22 PM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,044
Thanks: 80
Thanked 1,580 Times in 1,557 Posts
Default

Wow, great and fast service.... ;)

There may be more that you need to do. You said this:
Quote:
quote:by removing Handles Me.Load
Did you also remove those for other events, like Selecting / Selected / ItemDataBound and stuff like that?

If so, you'll find that a lot of stuff won't work. You'll need to explicitly set them. Here's how to do it:

1. Look in the code behind for event handlers. They follow the naming pattern ControlName_EventName.

2. Switch to Design View and locate ControlName.

3. Open the Properties Grid, click the Events button and then under EventName select the appropriate event from the list.

Hope his helps,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #6 (permalink)  
Old February 23rd, 2007, 10:20 AM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks Imar and Doug for your fast responses!! makes the book worth ten times its value and why I personally favour wrox over its competitors!!

I have added the missing events on the aspx pages from the code behind files. Does VB.Net not require the event handlers applied to the controls in the aspx files?

I am currently having trouble with getting the main content for the articles thus preventing me viewing or editing it.

When converting the code from VB I altered the SQL data reader "myReader" and I think this maybe causing the problem:

Code:
    public static Content GetItem(int id)
    {
        Content theContentItem = null;
        string cnString = ConfigurationManager.ConnectionStrings["Cms"].ConnectionString;
        SqlConnection myConnection = new SqlConnection(cnString);
        {
            SqlCommand myCommand = new SqlCommand("sprocContentSelectSingleItem", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;
            myCommand.Parameters.AddWithValue("@id", id);
            myConnection.Open();
            SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

            {
                if (myReader.Read())
                {
                    theContentItem = new Content(myReader.GetInt32(myReader.GetOrdinal("Id")));
                    theContentItem.Title = myReader.GetString(myReader.GetOrdinal("Title"));
                    theContentItem.IntroText = myReader.GetString(myReader.GetOrdinal("IntroText"));
                    theContentItem.BodyText = myReader.GetString(myReader.GetOrdinal("BodyText"));
                    theContentItem.ContentTypeId = myReader.GetInt32(myReader.GetOrdinal("ContentTypeId"));
                    theContentItem.CategoryId = myReader.GetInt32(myReader.GetOrdinal("CategoryId"));
                    theContentItem.Visible = myReader.GetBoolean(myReader.GetOrdinal("Visible"));
                }
                myReader.Close();
            }
        }
        return theContentItem;
    }


latest version can be downloaded from http://www.gkadata.com/files/CmsC.rar

Any help would be great!!! Thanks again.
  #7 (permalink)  
Old February 24th, 2007, 06:36 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,044
Thanks: 80
Thanked 1,580 Times in 1,557 Posts
Default

Hi .Netster,

The code in the Content class looks fine to me. There are, however, a few other issues.

First of all, all your pages have
Code:
AutoEventWireup="false"
instead of
Code:
AutoEventWireup="true"
in the page directive at the top. Use site-wide Search and Replace to change them all. With the setting to false, the default event wiring won't work. .NET can "wire up" standard events by its name, like Page_Load which handles the Load event of the Page. It only does that with the setting to true. In your current pages, none of the standard events like Page_Load will fire.

This is related to your question:
Quote:
quote:Does VB.Net not require the event handlers applied to the controls in the aspx files?
Earlier in the thread you said you removed all the Handles clauses from the code. That's the way VB does the event wiring. It basically says: this method "handles" some event for some control. So, when you, for example, double click a button, you get a method signature with a Handles clause in VB, while in C# you get the following code in the <asp:Button />
Code:
OnClick="Button1_Click"
There are a few more issues in your code.

In the ContentList page, you don't have the handler set up for the RowCommand, so you won't get the Delete confirmation. Add this code to gvContent:
Code:
OnRowCreated="gvContent_RowCreated"
Finally, there's another issue in the same page in the gvContent_RowCommand handler. Currently you have this:
Code:
int recordIndex;
int recordId;
recordIndex = Convert.ToInt32(e.CommandArgument);
recordId = Convert.ToInt32(gvContent.DataKeys[recordIndex].Value);
Response.Redirect("AddEditContent.aspx?Id=");
Notice you're not adding the recordId to the QueryString. So, whatever row you click, you always redirect to id=

Change the last line to:
Code:
Response.Redirect("AddEditContent.aspx?Id=" + recordId);
(and make the other changes) and you'll find that a lot of things will start working now (and hopefully start to make sense as well).

Cheers and good luck,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #8 (permalink)  
Old February 26th, 2007, 11:02 AM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks Imar!

I now have a fully working Wrox CMS in C#. I have updated FCKeditor to the latest 2.4 release and updated the stored procedure "sprocContentDeleteSingleItem" so it deletes the invisible entries as per your other post.

The C# Wrox CMS can be downloaded here: http://www.gkadata.com/files/WroxCmsCS.rar

I would like to thank Imar and Doug for all their help whilst converting this project!!

PS Let me know if I need to repost this as a new topic so you can add it as a sticky?


  #9 (permalink)  
Old February 26th, 2007, 11:06 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

No problem Netster, glad you got everything converted.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
  #10 (permalink)  
Old February 26th, 2007, 02:56 PM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,044
Thanks: 80
Thanked 1,580 Times in 1,557 Posts
Default

Hi .Netster,

Great work, and thanks for posting the update.

I asked Jim Minatel to either make this a sticky post. Jim: maybe a fresh post will be better, as this thread is now quite long and others may find it hard to find the latest version of the code at the end of the thread.

Thanks again,

Imar
 


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
C# Wrox CMS Code jminatel BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 June 3rd, 2009 05:41 AM
Wrox CMS in2minds BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 October 15th, 2008 05:14 PM
Wrox CMS - Altering the menu controls Eriskyne BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 October 15th, 2007 01:34 PM
Wrox CMS Deletions retroviz BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 9 February 3rd, 2007 04:55 AM
Wrox CMS retroviz BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 January 31st, 2007 01:23 PM



All times are GMT -4. The time now is 07:47 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.