i want to create an ASP.NET website, what i want to do is to create a page lets name it the main page "main.aspx", not MVC or razor pages.
Then inside this page i control and render the other pages using paramter in the url named "method" for example as following :
main.aspx?method=register : so the register page or view rendered in the main page.
main.aspx?method=users : the users page or view rendered in the main page.
My question is, what it the right choice to do this in Visual studio 2017 ?
if web forms is the right one, what is the main page should be "Default.aspx" or another page ? where i should exactly get the "method" value ? where i should put the template or the view of the "register" for example? and what is the expected content to be inside it ?
It sounds like you want a Single Page Application type of site.
My question is, what it the right choice to do this in Visual studio 2017 ?
Sure it is, if you understand what you are building. Try creating a new ASP.NET Core project with the SPA template, and see if that is what you are looking for. If so, I would strongly suggest checking out the [ASP.NET SPA Documentation(https://learn.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/build-a-single-page-application-spa-with-aspnet-web-api-and-angularjs)..
If you use Webforms, the template that can wrap other pages is called a MasterPage.
You don't need to pass the page name through a querystring, though. You can accomplish that with the URL Rewrite module or with Routing, but neither is necessary. The MasterPage will wrap any page that uses it automatically.
Here's an overview:
ASP.NET Master Pages
https://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx
Related
Is it possible to use a common layout page in MVC for multiple websites??
I have to use one layout page and i need to create multiple solutions of website and use the same layout page in all other websites
Try to use add existing item in visual studio add them as a link that way you will need to change only one file.
I know this may sound stupid but I am not able to include a controller rendering in the default Sitecore 8.1 layout.
I've created a controller in my MVC project and a controller rendering assign to the HelloController index action into sitecore. In the Home page I've added the controller as the sample rendering was done initially.
Someone said here that "layout was still pointing to default aspx instead of cshtml which caused this issue" I don't know how to change this.
In logs I've got an error like this:
Rendering control {id} not found for '/sitecore/content/Home'. Item id: {id}, database: web.
but the rendering exist in web database.
I've even tried in the new Experience Editor and got the same error but this time on master database which is absurd since the element was created on master database.
The controller works as expected when I create my own layout and add the controller to the page.
The questions are:
Why I cannot add a controller rendering to the layout?
How can I change that the layout to point to cshtml instead of aspx?
Unfortunately all the sample layouts and renderings are written in ASP.net WebForms and not in ASP.net MVC.
You can’t mix MVC and WebForms components in one single http request
Please install this package in your solution and it will work.
http://ctorio.aquasonic.ch/content/2014/04/Sample-MVC-1.0.zip
To point a layout to a aspx, you need to change the path to the cshtml file. Default layout . Check below picture:
Is it possible to create a .cshtml file (Razor) and process it manually? I would like to link to a page that does not currently have a controller, yet display a .cshtml page as a result. How would this be possible?
Not sure if its what you need, but Microsoft recently added something like this to the ASP.Net product line where you could use just Razor marked up web pages, and funnily enough they called it ASP.Net Web Pages.
http://www.asp.net/web-pages
I'm working on a website for a school project and I designed it in photoshop with 9 columns.
To make life easier I want to use the 960 grid system (Custom for 9 columns) in order to build the design in html/css.
Part of the projects requirement is that I need to use a master page and web forms in c# however I'm not sure how to implement the 960 framework within that.
does anyone have any experience with this?
It sounds like you're being forced to use ASP.Net Web forms. I'd typically recommend you use ASP.Net MVC instead, and it does support Master pages, but really everything is a view, and I expect you would get push-back from the professor. So, to keep with the standard ASP.Net Web forms approach, you should create a new ASP.Net WebSite, and check off that you want a master page. Then Visual Studio will create the Master page for you, and any new aspx pages you create you can click a box to have them inherit from the master page.
If you look at the .Master page, you'll see the same HTML you would see on any site, including the , and tags. You should just include the .css file that contains your 960 framework file, just like you would on any Web page. Then the rest f the page will use the 960 grid, and you can put the necessary col# classes inside the class tag (or CssClass for ASP.Net controls) to get the display to work correctly.
I program php, but I am trying to get into c# asp.net. In php I can make forms, custom html, etc into a seperate php file and just include it on the page that I desire. I understand asp.net has a master page which allows you to set the template for the whole website, but what If I want just a row of buttons to be on SOME pages, and not all? something separate to the master page that can be included on any page i desire? Also when its controllers is that when I use .ascx?
Look at User Controls. You can program a control that consists of a row of buttons and then put it on whichever pages you like.
There are two different approaches to ASP.NET nowadays.
ASP.NET WebForms:
Each page (.aspx) can have a Master Page (.master). Each master page can further have its own master page. Master pages are optional altogether, but if present, at least one in the heirarchy will typically have the opening and closing html, head, body, and form tags.
Each page (and master pages too) can reuse html/logic within itself through Web User Controls (.ascx), for instance if you wanted to create a reusable comment box "control".
ASP.NET MVC:
Each View can have a master layout.
Each View or master layout can trigger the rendering of child/partial Views, for further reuse of html/logic.
Nowadays, if coming from PHP, I'd learn ASP.NET MVC instead of WebForms if I were you.
As DuckMasetro. Said, we can have master Page Concept. It Is easiest way to do.. You can Design master pages in Designer mode with liitle efforts. then Just Use MasterPageFile="url" this property in your Webforms Page Directive at the top of your aspx. page
Tutorials for Begginers
Documentation for Master Page in ASP.net