Create a new page in asp.net on button click - asp.net

I'm trying to create a portfolio website where students can log in, choose from a selection of templates and then edit the content.
The users page is already set up but contains no html or asp.net.
I want to have it so that when the user selects the template and clicks the button, the code from that template is then written into their page.
Any ideas how I could do this?

Creating physical pages is not a good idea.
What you rather can do is to have your "pages" in the database and expose them through a url facade built on url rewriting.
A simplest example would be - you have a table, PAGES with Name and Body. Pages can be accessed with ShowPage.aspx?page=PageName. However, a facade exposes them as Pages/PageName.aspx which is internally rewritten into the ShowPage.aspx?page=PageName.
It doesn't really matter if you code agains WebForms or MVC, the general idea remains the same.

Related

How to make the country name to be a part of the URL in Asp.net core Razor pages

We developed a website using ASP.net core Razor Pages so we have some pages in the website served through URLs like
Domain/Solutions
Domain/solutions/details/1
Domain/aboutus
and other many links of course
After completing the development the customer requested to allow the user to select the company branch before browsing the website so the home page of the site will contain multiple cards one for each branch, for Example, "Dubai Branch, USA Branch, ...."
If the user clicked Dubai Branch for example we need all the URLs to contain that branch as a parameter like following
Domain/dubai/solutions
Domain/dubai/solutions/details/1
Domain/dubai/aboutus
We need to catch "dubai" as a parameter with all the subsequent requests to filter the content of the pages accordingly and to do this change at a minimal cost, first is that applicable? how to achieve that without many changes
You can mark part of a URL as a param like that
Domain/{branch}/solutions
Domain/{branch}/solutions/details/1
Domain/{branch}/aboutus
so you will be able to read it in your razor page behind code and customer will be able to sent there anything.
you can do this using Area like dubai,usa etc but you need to create separate code for each area.
another option is dynamic routing .

How do I remove form pages from browser history in ASP.NET Core

I have a simple ASP.NET address book application.
In the application the user can:
Get a list of contacts
Click a contact to go to an edit-page
Edit the contact
Press save and go back to the list
Now: If the users clicks the browser back button at this point in time the application goes back to the edit page - which is NOT what the user expects (the user expects to go back to the page before the list).
The general problem is these temporary/edit pages that you would never want to navigate back to - is there a pattern for handling this?
I can think of two solutions
Don't have separate edit page but use javascript to show edit form on detail page
When serving edit page check, that referrer header is not from contact list but from contact detail. If it's list page url then redirect to detail page
Imho option 1 is cleaner and option 2 probably easier

show previous data when switching between content pages

I have a site with a master page and a number of content pages. I do a search for data in one page and then in another. Often the selected result from the first page should populate some of the search criteria in another. How can I switch back to the previous page and retain the search results?
I have the site working when the user controls are all applied to the one default.aspx page, but the page is just getting too big.
I use a Telerik RadTab with RadPageview in the single page and an asp ContentPlaceHolder in the master/content page.
I understand your problem. Having everything on one page means the search is remembered but your performance suffers. You want to change it to separate pages but still retain the search.
I've written a Navigation framework that will help you, http://navigation.codeplex.com/
In the documentation I build a sample web project that has a search page with a Hyperlink from each search result going to a details page. Then there is a link on the details page that goes back to the search page and retains all the searching (and paging) information and restores the search results exactly as before.
Let me know if you're interested and want any help with it.

Auto-associate page metadata?

Links require SDL Live Content login.
We can choose default schema (and a mandatory option) in folder properties. New components in these folders will have the schema selected with appropriate fields filled out.
We can choose default page template for structure group (SG) properties. New pages in these SG will have the page template selected.
Do we have a similar option for page metadata such that in a given SG, author gets both page template and predetermined page metadata (fields) for either:
page creation
page template selection
We can do this easily with Inline Editing (SiteEdit) and page prototypes. But how would you configure or implement this type of requirement with the Content Manager Explorer?
I'd say there are a number of ways to achieve this:
1) Using the UI 'Page Types' - If the page you are using as the page type this should keep that same metadata. *I've not tested this!!! maybe you could confirm?
2) GUI extension - When a page template is selected a page metadata is selected based on the page template.
3) Event system. I'm not sure how well this would work as it would likely have to be on the creation of the page (checking if a default template is used) or on save if a template is used and a metadata schema isn't selected... but then if there is mandatory metadata etc etc.
4) The page template. This will set the metadata (on publish or preview) - or warn a user that a specific metadata should be set for this given page template.
Hope this helps.
Thanks
John
Very interesting question and I can see the benefits of this functionality for Editors. I don't have the answer for you. But AFAIK, even event system might not be relevant here since there are no events fired when you start creating a page unless we save the page. GUI Extension a possibility?
When you create a new item, this takes place via the GetNewitem() method in the API (or GetNewObject() in old money). I always thought there should have been separate events system hooks for this activity than for that of modifying an existing item. I once suggested this on ideas.sdltridion.com with regard to Components, however someone referred me to the OnSchemaGetInstanceDataPost event hook, and the discussion was over.
So in the case of a new component, the schema is automatically queried, and via the hook, you can interfere with the default data. So far so good, but I still believe that it would be generically useful to be able to modify the default data of any item type when first created.

ASP.net webform design

I can't figure out a good design for this.
I have an edit product page. It allows you to change basic product details, product name etc.
Then I have a function to upload images of the product.
I also have a small page for adding different prices based on date ranges for the product.
What I can't figure out, is how to have these on the same page so as not to have a billion tiny pointless pages when I would much rather have them all on one page.
ASP.net webforms seems to only allow 1 form per page!
ASP.NET Webforms allows only one form per page, but you can create interesting UIs without hitch.
Here is an Open Source Codeplex Project ShoppingCart.NET, download it and check the Product Catalog CMS section. That will help you to learn the trick...
All the best
You don't need more than one form. You just hook up a button_click event for the different buttons on the page, such that only the relevant code is executed when the user clicks one of the buttons.

Resources