Showing posts with label pages. Show all posts
Showing posts with label pages. Show all posts

Monday, March 26, 2012

Design approaches, AJAX of Master pages


Hello !

I'm migrating a website, all done with frames, from VS2003 to VS2005.
The layout of the website is a classical three columns with a header and a footer.

I want to remove frames but I would like advice on wether to use Master page or only AJAX.

Using AJAX, I would have one main page with the header and left column, clicking options on it
would load a HTML, CSS and javascript in the center column.
Fast and responsive but maybe hard to maintain and test.

Using a Master page, I guess I would have less changes to do since all the placeholders of the master page
would now be set as children of the master page. I haven't used Master pages yet so maybe
I don't understand the technology correctly.

Does anyone had the same concerns?
Can anyone tell me the pros and cons of this ?
Should I use a mix of the two approaches ?

My english is not perfect and I'm sorry for that, don't hesitate to ask for clearer details.

Thanks for any help !
Claude

You are correct - you do not understand the pratice of master pages correctly.

Masterpages in the Visual Studio 2005 enviroment are design time only. They are used as a way to manage a single layout across multiple content pages. When your site is complied or rendered, you end up with 1 page only. Masterpages should not be confused with frames in any way shape or form, they are not the same technology at all.

To understand this better - basically what you are doing is defining your layout, graphics, wrappers...etc in a master page. This is to maintain consistancy across all pages that would incorporate the design of that master page. So you can imagine a top header, a left column with links, and a center content area that you'd leave blank. In your content pages, you'd create the elements required to render content in that center area, without having to redesign, or duplicate the top and left column on each page. This is DESIGN TIME only.

When the pages are created and rendered. It'd be exactaly the same as designing your layout on each and every page. The pages are combined and sent down to the browser as a single html page, and nobody is the wiser.

To answer you're question. You should use Master Pages, AND javascript and Css (if thats your chosen technology) to render your pages. Using Masterpages for your layouts, and javascript css to render the center areas.

Master pages are "templates" that you build content pages around. They are not render time "frames".

Saturday, March 24, 2012

Deployment

I decided to start learning how to use the AJAX controls in my ASP.NET pages, so I made a simple website with a few controls on there to test. It works fine when I run the page from localhost, but when I tried to use it from a webspace that I have it gives me some errors such as:

Line 28: <compilation debug="true">
Line 29: <assemblies>
Line 30: <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Line 31: <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
Line 32: <add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

Here is the web address of the site if you want to try to run it:

http://cpt255.tech.purdue.edu/TA2/EGIS/EGIS.aspx

Hi,

are you sure the ASP.NET AJAX Extensions were installed on the server? If not, it won't work. Please check with the administrator or hosting company to be sure.

Grz, Kris.


Is ASP.NET AJAX installed in the environment you are using? I got that error on our first deploy of AJAX and it was because the sysadmin's didn't install AJAX yet. Also see if you can put the DLL's in a 'bin' folder in your app if they haven't deployed it to the server yet. That should clear it up...

Dapanther


Dang Kris, you beat me to this one LOL

Dapanther


I didn't realize that the extensions had to be installed on the web server as well. Thanks for the info guys.

TheSwazz:

I didn't realize that the extensions had to be installed on the web server as well.

Yes, the extensions get deployed in the GAC of the server/machine. It's under Microsoft support meaning it'll get supported for the next 10 years, 24/24, 7/7.

Grz, Kris.

Wednesday, March 21, 2012

Define a PageMethod in a MasterPage

I have a web site that uses Master/Content pages and I have a PageMethod that I would like to make available to a any of the content pages. So I defined the method like I would in a Content Page:

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Text;

using System.Web;

using System.Web.Security;

using System.Web.Services;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Web.Configuration;

publicpartialclassMasterPage : System.Web.UI.MasterPage

{

[WebMethod]

publicstaticstring MyMethod()

{

//Some Code Here

}

}

And I already have my script manager setup on the master page as follows, which works for all my PageMethod calls from Content Pages:

<asp:ScriptManagerID="masterPageScriptManager"runat="server"EnablePageMethods="true"EnablePartialRendering="true">

</asp:ScriptManager>

However, when I try to call PageMethods.MyMethod(MyMethodCompleteHandler); I get our favorite error, "PageMethods is Undefined." Is it possible to define a PageMethod in a MasterPage like this. If so what am I missing?

Thanks

Patrick

To be able to invoke that MyMethod

you need first to cast the MasterPage property of a page to your class (MasterPage) and then invoke it.

So if it was in the code behind of a content page to be able to invoke it you should write sth like :

string result = ((MasterPage)this.MasterPage).MyMethod();



Yani, I think he's talking about fromt eh javascript side.

On an unrelated note, mnogo mi obicham Bulgaria! Moja jena e bulgarka i nia otidame tam v sofia za 2-3 cedmitsi prez ljatoto vseki godina.

Paul (my apologies for grammar and spelling)


Hi Paul,

you are right about the javascript.

However, my point was that defined on the master page this static method does not become a page (content page) method. The master page is not a base class for the content pages, moreover it is a static page.

For this case it would be more suitable to create a web service, that will be accessible from everywhere.

Cheers,

Yani

PS: Paul, it is very nice you have learn some Bulgarian :)) Congrats!Wink


To answer the original question, I looked at the response in Fiddler and it looks like the Master page pagemethod doesn't get generated. I'm not yet sure how to work around that, I'll give it some thought.

Patrick,

I believe you won't be able to accomplish what you're trying with PageMethods.

The EnablePageMethods will assume that the method is defined in a.aspx page. This is why it is called a "Page Method".

If you want the method be available to all pages, why not use a simple webservice?

Default Master Page

As I read the Labs, Microsoft is highly suggesting the use of Master Pages in Atlas applications to simplify the the creation of Atlas applications. What about adding a master page with the necessary stuff in it when an Atlas application is created in the IDE.
WallyThe ScriptManager control works better for generating script references than using shared references stored in a master page.
In my humble opinion, the labs are giving some bad advice. I see master pages being abused in the newsgroups as a container for common code and functionality, which I feel is going to be a maintenance problem later in the app's lifecycle.
http://odetocode.com/Blogs/scott/archive/2005/09/10/2179.aspx
I'd be more comfortable if the common Atlas goo was defined in (or injected from) a base class I derive from Page. If the common goo is really generic enough, perhaps the framework can automatically inject what it needs based on a property we can set before OnInit, e.g. <% @. Page AtlasEnabled="true" ... %>.

Default Button in master pages - using Ajax

Hi,

My application uses master pages and now recently am using Ajax features. I wanted to handle the enter click in search pages. So i used the defaultbutton property of the page that sets to the control id which we specify when enter is clicked.

But the problem i have is when the focus of the cursor is on another button and i click enter from keyboard it still fires the search event instead of the buttons event.

Can someone explain the behaviour.

Thanks in advance.

Regards,

Rajesh

Setting the default button does just that... sets the default button that gets clicked when the enter key is pressed while on the page. Therefore, no matter what other button has focus on the page, hitting enter fires off the default.