Error appeared when I changed default page in visual studio - asp.net

First, I did not like the index.cshtml page is that it contains the signature of Web API ASP.net, the API link, ...so on. And it also it contains the footer as '2015 # My Asp.net Application'.
So, is there a way that I can get rid of the header and signature? I found the solution as that could be at the master page, but I couldn't find the master page with extension (.master) in my application.
Please help me in getting rid of the header and signature of Asp.net Web API.
Second, I set another page as 'Set page as Start page' or as default page. Then when I changed my mind and came back and made the index.cshtml page as default page as it was, I got Server Error (page not found).
Please help me in either one way where I can create a new html page to add my code in it, and I can make it as start page without problems.
Or at least, let me fix the error that occurred in the index.cshtml page, where I can come back to it and use it again.
Thank you

In MVC razor the master page is referred to as the _Layout.cshtml page it can be found inside Views->Shared.
To set the default page you would have to set the default action and controller in the routing table

Footer
Ctrl+Shift+F Search Entire Solution for: "My Asp.net Application". This displays _Layout.cshtml as a search result.
Default Page
Go To Project > Properties > Web.
Remove Start Action Specific Page (make it blank).

Related

Can we set form tag in master page as well as aspx page in asp.net

I getting the error i.e. a page can have only one server-side form tag.
I know the solution of this error, that if I remove the one of the form tag from master page or aspx page then this error will remove. But I want to use form tag in both form i.e. master page and simple aspx form. Because .net tools I am using in master page as well as in aspx page. So, to run the .net tools we want to create under form which is runat="server". But by doing this it shows the below error. Please give me some hint or any solution to solve this issues. Thank You.
There can be only one form tag , ideally form tag in the master page will be suffice . Can you tell us why you need form tag in aspx page ? Please share the code that will help us to get the work around for your use case.

Drupal webform form action

I'm adding a form to a Drupal website. I've created a new page, and created a webform, the webform has been assigned to the page content as a block.
The problem I'm having is when submitting the form, instead of showing the errors of the form at the top of the page like the rest of the forms do, the form action is set to the individual web form page, and any styling/content blocks disappear.
Essentially what I need to do is ensure the form posts to the same page, if I edit the form action in dev tools, the errors show fine at the top of the page.
EDIT: Should also add - I've setup the page and wbeform as per all the others, and they all function as they should and post to the same URL as the page.
Any help appreciated.
Thanks
If you are using the Webform module then you can go to the configuration page of the block in the 'Blocks' section, and look for the following checkbox:
Show all webform pages in block
The description under the checkbox tells you that anything that has to do with the webform (includes errors) will be shown on the current page, instead of redirecting you to the original webform page:
By default multi-page webforms redirect to the node page for all pages after the first one. If checked, all pages will be shown in the block instead.

Redirecting users to the same Tab in IE in ASP.net

I am redirecting users to a page based on the value I picked from the dropdown.
Response.Redirect("showdetails.aspx?id="+ id);
It is working absolutely fine.
Everytime the user selects an iD it is opening a new tab or page instead of opening in one page.
How can I make sure that it opens in same page instead of opening multiple pages?
Thanks
[Edited due to rethinking]
What you are describing doesn't seem like normal behaviour.
Does the same thing happen on more than one client PC?
If not it's probably a local config issue.
...or...
is the ASP page called via a server-side control with the following attribute:
OnClientClick=”aspnetForm.target =’_blank’
If so, that's why.

Strange Problem with asp.net website

I've built an asp website and i have the following issues:-
i'm using a master page in it and have defined two contentplaceholders one in head one in content, and i've specified the page title in the top most directive at the #page directive but the page title doesn't show up. I have to manually add a tag for it.
Secondly when i create a content page from a master page it creates it and when i rename it, it doesn't rename it's class. It remains _Default, thus every page was having an inherit to _default.
Most importantly
I'm using a page to enter and view data to the database. I've used a boolean called isadmin which i set according to credentials at page load. and i'm added a panel where it's visible property is set to Visible = '<%#IsAdmin %>'. It works properly when i run it through the visual studio environment but when i publish it and run it doesn't work and the panel just comes and stays there. Why is it happening? Any idea?
Thanks
The Visible problem is fixed as i had to enable windows authentication on the server. Awaiting answers for the other two issues. Thanks
Try to add a <head runat=server> to the master page. Only then ASP.net can "see" the tag and modify it
It is not that bad that several aspx-pages have identical class names. ASP.NET 2.0 started to process every page as its own compiling unit or so. Pages cannot see each other. There is a special directive to make pages see each other and instanciate or manipulate them. So it should not do much harm
Maybe you did not test this correctly and are mistaken that it DOES work in Visual Studio??? But in any case I would suggest that you move your logic into OnInit, then it runs much earlier. I think the control tree is build before Page.OnLoad. What you do is data binding, that might run only if DataBind is called, I'm not sure
Or use the safe way: Make IsAdmin a property so that it initializes itself on first call and caches the result in a variable
Regarding question #2 - add your content pages via Project -> Add New Item, and name it appropriately there. That way the naming is consistent and correct throughout.
Regarding #3, what HTML is output when you run it from the server?
your first issue can be solved by filling out the title part of the #Page directive in your .aspx pages. The master page will display that text in the browsers title bar.
and prob #2 should be solved by adding the files using the file add option in visual studio.

Why is my web control null?

I have a web site in asp.net that uses a master page. In this master page I have a multiview control with one view that has all the content for the content pages and one view that has some local content to the master page where I show error messages from all content pages.
In this error view I have a asp.net Label control that displays the error messages. Usually the label works fine, but in some few cases the label is null, which renders a NullReferenceException. Now I have handled this case by checking if the label is null before using it, but still my question is:
Why is this label null? What are the circumstances that can generate this?
EDIT: In the master page I have a method called SetErrorText that takes a string and sets the label. I'm calling this method from the content pages' Page_Load method, and this generally works fine. In all but two cases (that I've discovered so far) the label is initialised, and nothing separates these two cases from all the ones that work.
Also, all other controls in the master page are initialised, such as the View-control that houses the label.
When the Page_Load of a content page rolls around, the master page should be populated.
It seems that the problem was one of sloppiness. Someone had forgotten to delete the auto-generated Content-controls that Visual Studio throws in on all content pages where the master page has a ContentPlaceHolder-control.
If a content page has a Content-control, all controls that are placed in the ContentPlaceHolder-control on the master page will be null, it seems.
What method on the master page are you accessing the label from? Depending on the stage of the page lifecycle, the label control may not have been loaded yet
Could you be accessing it before it is created? Check the page lifecycle: http://msdn.microsoft.com/en-us/library/ms178472.aspx
I had a very similar error. In my case it was caused by .NET compiler wierdness related to the control designer file. Even if the designer file has the controls defined correctly, delete it, re-generate it and rebuild (make sure to rebuild, don't just 'build'). See the top answer here for how to do regenerate the designer file:
How do you force Visual Studio to regenerate the .designer files for aspx/ascx files?

Resources