Archive for April 9th, 2008

Nested Master Pages in ASP.NET?

Wednesday, April 9th, 2008

You can write a content page that is itself a master page, allowing an arbitrarily deep nesting of master pages. This technique can be useful when your application is broken into sub-applications that need to inherit a common branded look but still be able to define their own customized layout template within the brand. The following listing shows a master page that would serve as a content page for our first master page example.

<%@ Master Language=”VB” MasterPageFile=”~/try.master”
CodeFile=”trychild.master.vb” Inherits=”trychild” %>
<asp:Content ID=”Content1″ ContentPlaceHolderID=”mainContent” runat=”Server”>
<div>
<asp:ContentPlaceHolder ID=”main1″ runat=”server” />
</div>
<div>
<asp:ContentPlaceHolder ID=”main2″ runat=”server” />
</div>
</asp:Content>

<asp:Content ID=”Content2″ ContentPlaceHolderID=”sideContent” runat=”Server”>
<asp:ContentPlaceHolder ID=”side1″ runat=”server” />
</asp:Content>

Notice we must obey the rules for a content page in this master page, that is, we can only define content inside of Content controls. The ContentPlaceHolders inside of these controls can then be filled in with web forms addressing the IDs of the nested master page. A web form cannot reach the ContentPlaceHolders in the master page above it’s own master page.

<%@ Page Language=”VB” MasterPageFile=”~/nested/otcchild.master”
AutoEventWireup=”false” CodeFile=”Default.aspx.vb”
Inherits=”_Default” title=”Untitled Page” %>
<asp:Content ID=”main1″ ContentPlaceHolderID=”main1″ Runat=”Server”>
<h4>Content1</h4>
</asp:Content>
<asp:Content ID=”main2″ ContentPlaceHolderID=”main2″ Runat=”Server”>
<h4>Content2</h4>
</asp:Content>
<asp:Content ID=”side1″ ContentPlaceHolderID=”side1″ Runat=”Server”>
<h4>Content3</h4>
</asp:Content>

Master Pages and Configuration
There are three ways to associate a web form with a master page. You can use the Master attribute in the @ Page directive, and you can write to the MasterPageFile property in the PreInit event or earlier. We’ve seen examples of both of these techniques. Any web form using the Master attribute of the @ Page directive or setting the MasterPageFile property programmatically will override the web.config settings.
We can also assign a default master page for all web forms in a site in our web.config file using the <pages> element. An example excerpt from web.config is shown below.
<configuration>
<system.Web>
<pages master=”try.master” />
</system.Web>

</configuration>

Posted by Mahesh ( Tryangled )

How to Add google map in your site using asp.net?

Wednesday, April 9th, 2008

using following steps to add google map in your site.

1. Get a Google Maps API key from here:
http://www.google.com/apis/maps/

2. Download the SubGurim wrapper dll from here:
http://en.googlemaps.subgurim.net/descargar.aspx
3. Unzip it, and put it in your \bin directory
4. Add it to your toolbox by
Tools -> Choose Toolbox Items -> Browse -> Select the .dll file -> OK
GMap will now be in the ‘Standard’ area of your Toolbox.
5. Add a new webpage.
6. Drag the GMap from the toolbox onto the page. A new instance of the GMap will appear on the page, with the name ‘GMap1′
7. Add the following lines to your web.config file:

<appSettings>
<add key=”googlemaps.subgurim.net” value=”YourGoogleMapsAPIKeyHere” />
</appSettings>

Dim sStreetAddress As String
Dim sMapKey As String = ConfigurationManager.AppSettings(”googlemaps.subgurim.net”)
Dim GeoCode As Subgurim.Controles.GeoCode
sStreetAddress = “100 Russell St. Melbourne. VIC. 3000. Australia”
GeoCode = GMap1.geoCodeRequest(sStreetAddress, sMapKey)
Dim gLatLng As New Subgurim.Controles.GLatLng(GeoCode.Placemark.coordinates.lat, GeoCode.Placemark.coordinates.lng)
GMap1.setCenter(gLatLng, 16, Subgurim.Controles.GMapType.GTypes.Normal)
Dim oMarker As New Subgurim.Controles.GMarker(gLatLng)
GMap1.addGMarker(oMarker)

Posted by Mahesh ( Tryangled )