Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950
This is the forum to discuss the Wrox book ASP.NET MVC Website Programming Problem Design Solution by Nicholas Berardi, Al Katawazi, and Marco Bellinaso; ISBN: 9780470410950
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 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 Search this Thread Display Modes
  #1 (permalink)  
Old September 2nd, 2009, 11:43 AM
Registered User
 
Join Date: May 2009
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default C# Base to VB.net MyBase

I am building the 'TheBeerHouse' project in vb.net (the book is written in C#). Once I understand the concepts, I can usually convert it to vb. However, there are a few areas that give my some problems (which I will address individually). The first issue I have is the C# 'base' to VB 'MyBase'.
Here is the C# code I am trying to convert:
Code:
namespace TheBeerHouse.Configuration
{
 public class TheBeerHouseSection : ConfigurationSection
 {
  public readonly static TheBeerHouseSection Current = (TheBeerHouseSection)WebConfigurationManager.GetSection("theBeerHouse");
  [ConfigurationProperty("articles", IsRequired = true)]
  public ArticlesElement Articles
  {
   get { return (ArticlesElement)base["articles"]; }
  }
 }
}
And here is VB.Net converted code:
Code:
Namespace TheBeerHouse.Configuration 
    Public Class TheBeerHouseSection 
        Inherits ConfigurationSection 
        Public Shared ReadOnly Current As TheBeerHouseSection = DirectCast(WebConfigurationManager.GetSection("theBeerHouse"), TheBeerHouseSection) 
 
        <ConfigurationProperty("articles", IsRequired := True)> _ 
        Public ReadOnly Property Articles() As ArticlesElement 
            Get 
                Return DirectCast(MyBase("articles"), ArticlesElement) 
            End Get 
        End Property 
    End Class 
End Namespace
My understanding of this conversion is that I need to grab the attributes of the <articles> element under the <theBeerHouse> custom section in the web.config file.

This code does not compile and the get the following error: 'MyBase' must be followed by '.' and an identifier.

Thanks,
  #2 (permalink)  
Old September 2nd, 2009, 02:22 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Try this instead:

Code:
<ConfigurationProperty("articles", IsRequired:=True)> _
Public ReadOnly Property Articles() As ArticlesElement
    Get
        Return CType(Me("articles"), ArticlesElement)
    End Get
End Property
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
The Following User Says Thank You to Lee Dumond For This Useful Post:
jpatrick (September 2nd, 2009)
  #3 (permalink)  
Old November 16th, 2009, 02:45 PM
Authorized User
Points: 73, Level: 1
Points: 73, Level: 1 Points: 73, Level: 1 Points: 73, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: Coventry, Warwickshire, United Kingdom.
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
Default VB Version of the Code

Do you have a date when the VB version of the code might be ready?
__________________
Thanks, wagham

Last edited by wagham; November 16th, 2009 at 02:46 PM.. Reason: To make it clearer
  #4 (permalink)  
Old November 16th, 2009, 03:05 PM
Registered User
 
Join Date: May 2009
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Wagham, while doing research, I found this book by Chris Love:

http://www.wrox.com/WileyCDA/WroxTit...470187581.html

It solves all my issues regarding C# to VB.Net
  #5 (permalink)  
Old November 16th, 2009, 03:08 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

I would point out that the Chris Love book is straight WebForms, not MVC at all. Though they both deal with TheBeerHouse, they are two completely different books.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
  #6 (permalink)  
Old November 16th, 2009, 04:11 PM
Authorized User
Points: 73, Level: 1
Points: 73, Level: 1 Points: 73, Level: 1 Points: 73, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: Coventry, Warwickshire, United Kingdom.
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
Default

You're right, Lee, I have both Chris Love's book using WebForms and the similar book by Berardi, Katawazi and Bellinaso using MVC. Having got into Love's book, I do not find it as easy to follow as the earlier Bellinaso book with a similar title but using ASP.NET 2.0.

MVC is something new to me and so I will be using the new B, K & B book, but adding functions such as the Calendar of Events from Love's book. So, if there is no VB version of the code available, we'll see how good the C# to VB translators on the Web are.
__________________
Thanks, wagham
 


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

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
Base Page vs MasterPage.vb - Ch 6 jeff9315 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 June 21st, 2009 04:10 AM
.Net knowledge base PassHours General .NET 0 June 13th, 2008 04:55 AM
how to deploy vb.net data base projects er.narendraojha General .NET 1 February 5th, 2007 03:33 PM
MyBase.CreateChildControls samvan BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X 1 January 15th, 2006 06:26 PM
MyBase Keyword Little Shell VB.NET 2002/2003 Basics 2 May 2nd, 2005 05:18 PM



All times are GMT -4. The time now is 07:48 PM.


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