Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 create querystring and update sitemap nodes

Author  Topic 

-Dman100-
Posting Yak Master

210 Posts

Posted - 2009-06-03 : 17:23:30
I am using a SqlSiteMapProvider that creates a sitemap dynamically from a sql server database.

I also have a table in the database where I store page content that can be displayed dynamically based on the page that is being requested. Some pages have dynamic content and other pages just have static content.

here is my sitemap table:

CREATE TABLE [dbo].[sitemap](
[ID] [int] NOT NULL,
[Title] [varchar](32) NULL,
[Description] [varchar](512) NULL,
[Url] [varchar](512) NULL,
[Roles] [varchar](512) NULL,
[Parent] [int] NULL,
CONSTRAINT [PK_SiteMap] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO

Here is my web_item table that contains the data for pages with dynamic content:

CREATE TABLE [dbo].[web_item](
[item_id] [int] IDENTITY(1,1) NOT NULL,
[sitemap_id] [int] NOT NULL,
[item_sitekey] [varchar](50) NOT NULL,
[item_title] [varchar](255)NULL,
[item_body] [text] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
SET ANSI_PADDING OFF


web_item table has a foreign key relationship to sitemap table.

What I'd like to be able to do is programmatically generate a querystring and update the sitemap nodes for pages that have dynamic content.

For example, in my sitemap table, I have a record for the home page, about page and contact page...i.e. ~/default.aspx, ~/about.aspx and ~/contact.aspx

The default and contact pages simply contain static content. The about page contains dyanamic content.

So, when the about page is requested, I'm trying to figure out how I can programmatically generate a querystring and update the sitemap node so I can pass in a querystring value to a method that retrieves the content for that page.

I need to dynamically generate the querystring. So, the about page url in the database is:

~/about.aspx

but, when the page is requested, I want to add the querystring programmatically so the url becomes:

~/about.aspx?sitekey=1.0 ("1.0" is the item_sitekey value stored in the web_item table for the about page record.

Currently, I can hardcode the url in the sitemap table, but I want to dynamically do this so as my sitemap becomes larger and more complex, the generation of the url is automatic.

How can I accomplish this?

Any help is appreciated.

Thank you.
   

- Advertisement -