Using visual studio 2008. When I add a new aspx form to a project I am not offered the option to choose a master page even though there is one in the project. How do I turn that option on? It appeared automatically in the past.
When you add a new item make sure you select Web Content Form and not Web Form. Then you'll be able to select the MasterPage.
Related
I have just begun using ASP.net heavily.
In Visual Studio when I open a web form with a master page in design view, it is not really very comfortable to work with.
Is there any way to hide master page so that I can concentrate on my form ?
If not, can I use a user control as a web form and embed it into the actual form as a work around ? (I know it does not exist for this purpose)
Just remove MasterPageFile="~/MasterPage.Master" from the page header. when your design is complete add it again.
Any new page I add to VS2017 is not linking with its respective codebehind or designer pages:
Happens across all my projects and solutions
Right clicking aspx code does not show "View code" in context menu (works in existing pages)
Right clicking .aspx in solution explorer shows "View code" option and opens code behind as expected
Controls are not automatically added for reference in designer and navigation menu (changed autoeventwireup)
Intellisense in page declaration only shows 1 option ("db"), where normally it should show 15 or 20 options - new and existing pages
Compiles OK
I can add the reference directly to the deisgner page and am able to reference it in the codebehind
EDIT: Also the intellisense for all controls just says "db" too
This is not a problem in VS2015. I have both installed and have opened a solution in 2015 and the above problems don't exist.
The solution was to clear out my temporary ASP.net files, as per Kenan Deen's answer in this post:
I have been given the task to create a "Web Part" for a Sharepoint website. The reason i quote "Web Part" is because i don't think that it suits my needs.
With a User Control a developer is absolutely free in what kind of control he wants to add. This can easily be done in the (for example) MyUserControl.aspx file from the MyUserControl.ascx control. You can even add jQueryUI elements to the User Control like tabs etc.
So basically i need to be free in what kind of (HTML) elements i add to the page and what not.
Since it looks like this can't be achieved with a SharePoint Web Part i want to know if it is possible to display a User Control instead?
Is there a way to do this..??
If you use Visual Studio you can select "Create new Visual WebPart", provided it is SharePoint 2010 we are talking about?
This option gives you a ascx-file which you can treat like a normal usercontrol. It is automatically wrapped as a SharePoint-webpart.
See this walkthrough for more thorough information:
http://blogs.msdn.com/b/bethmassi/archive/2010/01/28/creating-a-sharepoint-visual-web-part-using-visual-studio-2010.aspx
You cannot add User control directly to a specific SharePoint page, but you can add to Master Page or Page Layout. (And only by SharePoint designer)
Another option is to create User Control add load it to Web Part, and add the Web Part to your page.
Edit:
As Rikard Uppström wrote, in VS2010 there is template named Visual Web Part that does exactly that for you, but if you work in SP 2007 you can do it yourself.
in Visual Studio 2010 I have a really big ASP.NET website project which has a bunch of user controls.
How do I determine all the .aspx pages where a specific .ascx user control is referenced throughout the project.
Thanks
Right click the class of your User Control and Select the below option.
Find All Reference
The simplest way I can think of is to just use the Find In Files (Ctrl/Shift-F) search dialog.
Find what: name of user control
Look in: Entire project
I have a web solution with Visual Studio 2010 and ASP.Net 4.0. In this solution there is a web site as well as a class library.
I added a new User Control to the site and was able to build everything. I was even able to publish with the new control. The issue arises when I try to reference the class name of that control in a different part of code. When I do this, I still am able to build / rebuild the entire solution. But when I try to publish, I get the error "type or namespace name could not be found."
When we publish, we always UNCHECK the box "Allow this precompiled site to be updatable" and we always CHECK the box "Use fixed naming and single page assemblies."
If I do a publish and UNCHECK the box "Use fixed naming and single page assemblies" it will publish just fine. But for some reason I can not get it to publish with that box CHECKED which is what I need to be able to do.
I have tried:
Cleaning the solution
Restarting Visual Studio
Restarting Computer
Clearing out .net temp files folder
Recreating the control
Putting everything in website into a namespace
Any help or insight would be greatly appreciated.
Thanks.
EDIT:
I figured it out. I was adding this new control dynamically. But I didn't realize it also needed registered on the page that I am using it on. After registering the control, everything worked as expected
When you want to use your web user control dynamically, as you use other .net controls like textbox, label etc. you need to follow these steps.
(1) Add a ClassName property in your control directive as below (in ascx file)
<%# Control Language="C#" AutoEventWireup="true" CodeFile="CustomControl.ascx.cs"
Inherits="CustomControl" ClassName="CustomControl" %>
Note : Make sure the ClassName & Inherits both are same as class name in the CS file.
(2) Add a Reference directive on the page where you want to use your web user control dynamically
<%# Reference Control="~/usercontrol/CustomControl.ascx" %>
Note : Reference directive is different then Register directive.
(3) Now you can add your user control dynamically anywhere on your page like below
ASP.CustomControl cuCtrl = (ASP.CustomControl)LoadControl("~/usercontrol/CustomControl.ascx");
//add dynamically created custom control to an existing panel or any container control on your page
pnlDemo.Controls.Add(cuCtrl);
Note : You can always include the ASP namespace in the using ;)
After this, you should not face any problem publishing even when checking the Allow this precomplied site to be updatable option.
I figured it out. I was adding this new control dynamically. But I didn't realize it also needed registered on the page that I am using it on. After registering the control, everything worked as expected.
I tried that and still have the same problem when publishing, either with reference tag or register tag it doesn't publish. Only way to work by now is to uncheck the "updatable site"