I can't get right url in asp.net - asp.net

i need your help.
I have an home button (it exactly is ) in masterpage use for all aspx. Pages is my folder name (it containts my aspx webpages) and it has an "Admin" folder inside (it containts my admin page). It works in all of pages except admin page. when I clicked "Home" from admin page I got "The resource cannot be found." error, and the Url in web browser's address bar is "localhost/Pages/Pages/Home"
I don't know why i get two "Pages" in the Url.
help me please
table>
<tr>
<td width="700px">
<ul class="menu">
<li>Trang chủ </li>
<li class="Parent">Sản Phẩm
<ul>
<li>Điện thoại </li>
<li>Máy tính bảng </li>
<li>Phụ kiện </li>
</ul>
</li>
<li>Giới thiệu </li>
<li>Góp Ý </li>
<li>Đăng nhập </li>
<li>Đăng kí</li>
</ul>
</td>
<td width="300px">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<asp:Label ID="lblUser" runat="server" Font-Bold="True" ForeColor="White"></asp:Label>
</td>
<td>
<asp:HyperLink ID="HyperQuantri" runat="server" Font-Bold="True" ForeColor="White"
NavigateUrl="~/HienThi/ThongTin.aspx">Thông tin</asp:HyperLink>
</td>
<td>
<asp:HyperLink ID="HyperThoat" runat="server" Font-Bold="True" ForeColor="White"
Visible="False" NavigateUrl="~/HienThi/Thoat.aspx">Thoát</asp:HyperLink>
</td>
</tr>
</table>
</td>
</tr>

It sounds like you may have some relative pathing issues with your links. This gets particularly tricky when you're using master/child pages or template controls in a site where you have various depths of folders.
Since you're using web controls, try renaming your links using the following format:
~/Pages/Admin/Default.aspx
The ~/ directive will tell ASP.Net to build the path of the link from the root of the site, so no matter which page the control resides on, it will generate the proper link.

Related

404 not found ! Why can't i write without extension?

I am using ASP.NET and I am trying to make a link in my home page to Login page and Register page. I am getting the error
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
I have this code :
<tr>
<td>Login</td>
<br />
<td>Register</td>
</tr>
the page is there where I said it is.
but if I write this code, it works.
<tr>
<td>Login</td>
<br />
<td>Register</td>
</tr>
Why can't I write without .aspx extension ?
I've seen enough examples where developers didn't write the extension.
What is the problem here? Why is this happening?
For example, here :
http://www.asp.net/web-forms/tutorials/aspnet-45/getting-started-with-aspnet-45-web-forms/ui_and_navigation
<AnonymousTemplate>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server" href="~/Account/Register">Register</a></li>
<li><a runat="server" href="~/Account/Login">Log in</a></li>
</ul>
when u don't want to show the exyensions u have to use httphandlers to mask the url other wise .net compiler don't know how to compile the code

<a href> and PostBackUrl both are not working

I am using asp.net CreateUserWizard to create a portal web site. The interface pages like below:
In the last step, I have a link to a pdf file. What I want is by clicking it, a pdf file will be opened. However it failed, it always go to the first screen(login web page).
The corresponding code of the last step:
<asp:CompleteWizardStep runat="server" ID="CompleteWizardStep">
<ContentTemplate>
<table style="font-family: Verdana; font-size: 100%;">
<tr>
<td align="center" class="style5" style="color: White; background-color: #5D7B9D;
font-weight: bold;">
Complete
</td>
</tr>
<tr>
<td class="style1">
Your account request was successfully submitted. Please download the
form and return it. You shoud receive an email response within 3 business days.
Thank you.
</td>
</tr>
<tr>
<td align="right" class="style1">
<asp:Button ID="ContinueButton" runat="server" BackColor="#FFFBFF" BorderColor="#CCCCCC"
BorderStyle="Solid" BorderWidth="1px" CausesValidation="False" CommandName="Continue"
Font-Names="Verdana" ForeColor="#284775" Text="Download Form" ValidationGroup="CreateUserWizard1"
PostBackUrl="~/admin/DownloadFile.aspx" />
</td>
</tr>
</table>
</ContentTemplate>
You see the code doesn't work at all.
Also PostBackUrl="~/admin/DownloadFile.aspx" is also not working, it is also going to login page. I heard that we enable Javascript something. But how to change my code since it is not in the code behind.
Many thanks.
It seems the ~/Admin/DownloadFile.aspx is protected and the user has no permission to access this file or Admin location as a whole.
You can put your DownLoadFile.aspx in unrestricted area

Why server controls are underlined when placed inside Content tags?

I have a Web Content Form containing a Div and various Server controls like DropDownList. When I run the application, it runs well without any errors, but when I view the HTML source, the Server controls are red underlined. On bringing the mouse over, say, DropDownList, a tooltip warning is displayed:
DropDownList is not a known element. This can occur if there is a compilation error in a website.
Edited
<%# Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="contentReportSchemesMenu.aspx.cs" Inherits="contentReportMenu" Title="Reports Menu" %>
<asp:Content ID="ContentReportMenu" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="divMenu" class="divMenu" runat="server">
<table id="tblMenuLayout" class="Options" runat="server">
<tr>
<td colspan="2" class="Top">Scheme Reports Menu</td>
<td></td>
</tr>
<tr>
<td class="Left">Report Type</td>
<td class="Right">
<asp:DropDownList ID="ddlReportType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlReportType_SelectedIndexChanged"></asp:DropDownList>
</td>
</tr>
<tr>
<td class="Left">Select District</td>
<td class="Right">
<asp:DropDownList ID="ddlDistrict" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlDistrict_SelectedIndexChanged" Enabled="False"></asp:DropDownList>
</td>
</tr>
<tr>
<td class="Left">Select Block</td>
<td class="Right">
<asp:DropDownList ID="ddlBlock" runat="server" AutoPostBack="true" Enabled="False" OnSelectedIndexChanged="ddlBlock_SelectedIndexChanged"></asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" Enabled="False" />
</td>
<td></td>
</tr>
</table>
</div>
</asp:Content>
A quick Google search soon found the solution: Delete the files from “C:\Documents and Settings[Username]\Application Data\Microsoft\VisualStudio\9.0\ReflectedSchemas” folder (or “…\VisualStudio\8.0\…” if running Visual Studio 2005) in Windows XP. In Windows 7 it is under "C:\Users{User Profile}\AppData\Roaming\Microsoft...etc". Remember also the "VisualStudio" part of the path will be different depending on the version installed.
I closed Visual Studio (always a good ideas for changes that will affect the IDE), deleted the files then re-opened the project. The warnings were gone.
I found references to this solution at:
http://forums.asp.net/t/1205528.aspx
http://blogs.msdn.com/mikhailarkhipov/archive/2005/04/21/410557.aspx
FYI, the search term I used in Google was “element is not supported”.
I don't know why this happens but I do know there are some flakey domain profile things happening in the network environmnet.
You're receiving this error because the table is running at the server, but the tr and td elements are not. When you specify runat="server" on a table element, it expects child elements to run at the server as well.
There are two easy ways to verify this:
Remove runat="server" from the table declaration;
Take the DropDownList(s) outside of the table
Try one of these two options, and see if it fixes the problem.
EDIT
Make sure that the ContentPlaceHolderID on the content form matches the ID of the corresponding content area in the master page. If that doesn't fix your problem, try creating a new content form, applying the advice above, and add a control to the form in the content area. If there are no errors, then you know the issue is somewhere in your markup.
Try deleting the schema cache. To do this, close Visual Studio and delete all of the files in the following directory:
C:\Users\USERNAME\AppData\Roaming\Microsoft\VisualStudio\10.0\ReflectedSchemas
Once the files have been deleted, open Visual Studio again and the problem should be fixed.
You said that "when I view the HTML source, the Server controls are red underlined", but HTML source can not contains such elements like DropDownList because this is the ASP.NET control which is generated as HTML Select tag. Considering that common solution with schema cleanup is not helped you perhaps a problem is in an other place... I'll try to assume that you are opening ASPX/ASCX file itself using some third party editor which is not aware of ASP.NET controls, am I right?

ASP.NET - Image is not showing up

I have placed an image on the master page.
I see the image at design time.
But I don't see the image at run time.
What can be the problem?
I have tried to place the image on an image box. But it didn't work either.
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="Ice_Web_Portal.UI.MasterPage" EnableTheming="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>.::ICE Web Portal::.</title>
<link href="App_Themes/SmokeAndGlass/SmokeAndGlass.css" rel="stylesheet" type="text/css" />
</head>
<body >
<form id="form1" runat="server">
<table style="position: static">
<tr>
<td align="left" colspan="2">
<asp:Image ID="Image1" runat="server" ImageUrl="~/App_Themes/Banner.JPG" /></td>
<td>
</td>
</tr>
<tr>
<td rowspan="2">
<div>
</div>
</td>
<td style="width: 3px">
<asp:LoginView ID="LoginView1" runat="server">
<LoggedInTemplate>
<table style="width: 204px">
<tr>
<td>
Login Status :</td>
<td>
<asp:LoginStatus ID="LoginStatus1" runat="server" />
</td>
<td>
</td>
</tr>
<tr>
<td>
Login Name :</td>
<td>
<asp:LoginName ID="LoginName1" runat="server" />
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</LoggedInTemplate>
</asp:LoginView>
</td>
<td>
</td>
</tr>
<tr>
<td style="width: 3px">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td style="width: 3px">
</td>
<td>
</td>
</tr>
</table>
</form>
</body>
</html>
It sounds like you may have a URL mapping issue of some kind... For the ImageURL property try setting it to "~/Images/MyImage.png"...
Rather than storing an image directly in the App_Theme folder, create a folder for images and try to use that instead. The App_Theme directory is handled differently...
It sounds like an issue with Relative Paths in Master Pages to me. The solution is the tilda (~) character, which signifies the root folder regardless where the content page resides.
I just tested your code and it worked for me.
Have you tried it using multiple web browsers? (a caching issue perhaps?)
Are you manipulating the image in the code-behind?
I think your image files are not accessible on runtime.
Just paste this code in your web.config file and the images will be displayed.
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</configuration>
It is a relative path issue, change your stylesheet to:
<link href="~/App_Themes/SmokeAndGlass/SmokeAndGlass.css" rel="stylesheet" type="text/css" runat="server"/>
i had the same problem, it was permissions, just check images that show up in the web form and copy the same permissions to the img not showing up.
I know this is a long time question but i happen to see it now, i want to share with you all how i solve mine challenge:
Just replace bellow code in your web.config and put the image path as illustrated
<location path="Image Path">
<system.web>
<authorization>
<allow user="*"/>
</authorization>
</system.web>
</location>
Hope it help
Hmm..seems to be perfectly fine. Did you try to use normal HTML tags like
<img src="<sourceToImage>/App_Themes/Banner.JPG"/>
..just to see whether that works.
Another problem could be the UPPER-case "JPG" extension (although I don't know whether that really matters).
Check whether your stylesheet does some operations upon images.
Simple.
Create a folder Images inside your Project folder.
Place your image, e.g. logo.jpg, inside the Images folder
Back to your project, in your Image properties provide the relative path, i.e your ImageURL, as ~\Images\hlogo.jpg.
Your image will then display in the web browser.
In IIS 7 when you install the ASP.NET modules, static content is not installed by default. You will need to go into programs and features, then "Turn windows features on or off".
Under IIS section, drill down into WWW services, Common Http features, and check "Static Content".
Without that css, images, html, and other non-dynamic content will not show up.
I had a similar issue with my VB.NET application using IIS 8.5 on 2012 R2. I has to specifically add my image extensions (.jpg, .png) to 'Request Filtering' for my Default site in IIS 8.5.
try the below format:
("../App_Themes/Banner.JPG")

ASP.NET User control with ASP:CreateUserWizard

When using asp:login, asp:forgotpassword and asp:createuserwizard controls within an ascx. (e.g registration.ascx) it can't find e.g UserName, even though it exists within LayoutTemplate. Any idea how to fix this?
If you open smart tag for control in design mode,you shall see that there are steps that can be convertible to templates for customization.
CreateUserWizard http://img197.imageshack.us/img197/3823/7d4df5a594a1abdb8fdc8f1.png
For CreateUserWizard , press Customize Create User Step and you will observe that,control is converted into a table template which you can see how controls named i.e. UserName,Password...
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
<WizardSteps>
<asp:CreateUserWizardStep runat="server" ID="CreateUserWizardStep1">
<ContentTemplate>
<table border="0">
<tr>
<td align="center" colspan="2">
Sign Up for Your New Account</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
.......
Also know that If you wish to find control from inner templates , you must look for templates with FindControl method to reach the control you desire.
To Find UserName Control in above code,use
CreateUserWizardStep1.TemplateControl.FindControl("UserName") as TextBox
Hope this helps to solve your problem

Resources