PHP & MySQL to C# .NET

N

Nick Bolton

Hello,

Maybe a common case, but I really want to not so much as migrate from
PHP/MySQL to C# .NET but learn the new language.

I have made maybe 3/4 very simple systems using C# .NET, but they all
seem to be a little, well simple -- and not uniform at all.

When I use PHP, I always incorperate some kind of template system, so,
say I have a master template and a child template which is loaded
inside the master.

I am aware of the ASP 2.0 master page functionality, but upgrading to
VS.NET 2005 right now isn't really an option; so I'm going to have to
stick with 2003.

Could anybody shed some light on how I would go about maintaining a
constant feel to all my aspx pages? An alternative to the master page
functionality in 2005 perhaps?

Any help at all would be much appreciated!

Thanks,
Nick
 
A

Andrei Pociu

Hello Nick,

I use WebUserControls for header, footer, menus and other items that should
be the same on all pages. Very similar to using PHP's include() function (I
also come from a PHP & MySQL background).

Regards,
Andrei Pociu
 
N

Nick Bolton

Andrei,

Thanks for the reply! Glad to know I'm not the only lost developer from
a PHP background.

I just read a very interesting article on user controls and custom
controls by a guy called Solomon Shaffer (www.15seconds.com). I
reccomed anybody to have a look.

http://www.15seconds.com/issue/020319.htm
http://www.15seconds.com/issue/020430.htm

Glad I stumbled across this, it's shed a lot of light on the subject.
But what I still can't understand is why Microsoft have decided to
include "Master pages" in the .NET 2.0 framework. What's the
difference...? Is it just easier to use?
 
A

Andrei Pociu

I believe master pages are a different concept, they don't seem similar to
WebUserControls:

ASP.NET 2.0 introduces a new concept known as Master Pages, in which you
create a common base master file that provides a consistent layout for
multiple pages in your application. To create a Master Page, you identify
common appearance and behavior factors for the pages in your application,
and move those to a master page.
http://www.devx.com/dotnet/Article/18042

I haven't tried them yet but I'm planning to soon.

Don't give up on ASP.NET even though some things might differ a lot from
PHP, after you get the hang of it, you'll see it was worth it ;).

Regards,
Andrei Pociu
 
S

Sherif

Hello

The master template can be done with ASP 1.0, but you will have to implement
it yourself, and you will not have WYSIWYG from VS2003 that VS2005 provides
with master pages.
The idea is make one .aspx page with a PlaceHolder control, then override
the CreateChildControls method to dynamically load and add a user control
(.ascx) file to the PlaceHolder. Determining what .ascx file to use can be
done by query strings, url rewriting and reading the path, or any other
method.

Best regards,
Sherif
 
N

Nick Bolton

Sherif,

Nice idea, if it works, it sure beats loading several UserControls on
to a page at once, then just switching the visability.

How would I go about creating a new UserControl from a path? Don't they
have to be registered on the aspx page?

For example, say I wanted to load in "/Pages/Home.ascx" and assign it
to currentPage (which is a UserControl object). What method would I use
to do this?
 
N

Nick Bolton

Serif,

Found the LoadControl method, which works perfectly. Apart from one
minor detail, which I cant seem to fix...

Controls within my called UserControl don't seem to work... at all. Any
ideas why not? No errors are returned, the control just seems to not
bother running the associated event then posts nothing back to the
page.

InitializeComponent is however run, and the event controler for the
control is added, but as I said, nothing is actually run when a button
is clicked for example.
 
N

Nick Bolton

Well, third and final post in a row I should hope. Solved the problem!
All thanks to a top guy called Denis Bauer. He created a Control called
"DynamicControlsPlaceholder".

The issue I had yet to discover was that when I posted back to my page,
all the Controls with my PlaceHolder weren't being saved to the
viewstate. This means that the events could never actually be fired as
the UserControl had dissapeared.

As you may have guessed, the DynamicControlsPlaceholder solved this
very nicely indeed by... You guessed it, saving the view state.

http://www.denisbauer.com/ASPNETControls/DynamicControlsPlaceholder.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top