A few years ago I saw a asp.net web app that would on the fly change its content based on the values in the database. This was done seemlessly and without any code in the Page_Load event or any inline functions that would return a string. it would simply
look for tags like {dc:HomeWelcome} and go to the database, pull the contents of that tag and replace it.
I was wondering if anyone here would help point me to the right direction as to the best way to optimally do this.
Thanks for the reply, I'm actually looking for a more integrated and automatic method. I did some digging arround and know that the way to do it is through Page Inheritance.
My Problem is that I have never done this (created my own page inheritance class) so any help on this would be greatly appreciated.
My Problem is that I have never done this (created my own page inheritance class) so any help on this would be greatly appreciated.
I am not sure what you are asking for....you mean to say a BasePage inheriting from Page class, and then inheriting BasePAge from all other pages...in that case you got to write C# code, it cannot be done with no code...but if you use DataSources like SqlDataSource
or ObjectDataSourc, then that would take care of your data fetching...
Sorry man, for some reason this forum did not email me that I have received a reply.
yes, I was thinking that. I have no problem pulling the data from the SQL Server and assigning values to some labels or literals, What I'm looking for is for a way that I can just create a definition where on page.prerender or preinit or even load, the application
would look for all of the {dc:[SQLdataName]} and replace it with the corresponding data from the database (automatically and site wide). I have inluded a senorio below:
I navigate to "Page.ASPX"
before the system shows me that page it will look through the text on the page with the format of {dc:[SQLdataName]}
it will find one called {dc:HomeWelcome}
it will then go to the Database and fetch the value column where name = 'HomeWelcome'
it will then replace {dc:HomeWelcome} with "Welcome to page 1 of the site x" where this is the data in the database.
Like I said I can easily go through and place labels or literals, and change them one by one on page.load, but I'm looking for the most efficient method to do this and it seems to me that there should be something I can do to tell asp.net to do this for
me on a site/application wide scale.
Once agian thank you guys in advanced for helping out,
hnnp14
Member
37 Points
30 Posts
Dynamic ASPX page content
Feb 17, 2012 06:04 PM|LINK
Hi,
A few years ago I saw a asp.net web app that would on the fly change its content based on the values in the database. This was done seemlessly and without any code in the Page_Load event or any inline functions that would return a string. it would simply look for tags like {dc:HomeWelcome} and go to the database, pull the contents of that tag and replace it.
I was wondering if anyone here would help point me to the right direction as to the best way to optimally do this.
Thank you,
Hiva
ramiramilu
All-Star
95373 Points
14096 Posts
Re: Dynamic ASPX page content
Feb 17, 2012 07:41 PM|LINK
SqlDataSource with GridView would do that, without even a single line of code in C# - http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.aspx
thanks,
JumpStart
hnnp14
Member
37 Points
30 Posts
Re: Dynamic ASPX page content
Feb 17, 2012 07:45 PM|LINK
Hi,
Thanks for the reply, I'm actually looking for a more integrated and automatic method. I did some digging arround and know that the way to do it is through Page Inheritance.
My Problem is that I have never done this (created my own page inheritance class) so any help on this would be greatly appreciated.
Thanks,
Hiva
page inheritance
ramiramilu
All-Star
95373 Points
14096 Posts
Re: Dynamic ASPX page content
Feb 18, 2012 07:01 AM|LINK
I am not sure what you are asking for....you mean to say a BasePage inheriting from Page class, and then inheriting BasePAge from all other pages...in that case you got to write C# code, it cannot be done with no code...but if you use DataSources like SqlDataSource or ObjectDataSourc, then that would take care of your data fetching...
Thanks,
page inheritance
JumpStart
hnnp14
Member
37 Points
30 Posts
Re: Dynamic ASPX page content
Feb 25, 2012 05:24 AM|LINK
Sorry man, for some reason this forum did not email me that I have received a reply.
yes, I was thinking that. I have no problem pulling the data from the SQL Server and assigning values to some labels or literals, What I'm looking for is for a way that I can just create a definition where on page.prerender or preinit or even load, the application would look for all of the {dc:[SQLdataName]} and replace it with the corresponding data from the database (automatically and site wide). I have inluded a senorio below:
Like I said I can easily go through and place labels or literals, and change them one by one on page.load, but I'm looking for the most efficient method to do this and it seems to me that there should be something I can do to tell asp.net to do this for me on a site/application wide scale.
Once agian thank you guys in advanced for helping out,
Thanks,
Hiva
page inheritance