I have a virtual directory on my iis -portal, which contains images. I put an image tag in my asp.net form.
<img src="http://localhost/portal/images/button_right.gif" alt="Alternate Text" />
This is the code:
<%Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication15.WebForm1" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<img src="http://localhost/portal/images/button_right.gif" alt="Alternate Text" />
</div>
</form>
</body>
</html>
The image shows when I run the project, on the browser.
The image doesnt show in design time. - I see X, instead of an image.
I set all read write execute permissions alowed o the virtual directory.
You should never specify image src as an absolute path. Use ~ to address your application path. It requires the runat="server" attribute since it is substituted by IIS at server.
<img runat="server" src="~/images/button_right.gif" alt="Alternate Text" />
Related
I'm starting to learn ASP.NET and it's the little things that are really annoying with Visual Studio Web Dev Express. I keep getting the error "Content Not Supposed To Be Outside 'Script' or 'asp:Content' Regions" - so I put content inside an asp:content container and it doesn't disappear. I also get the same sort of error with declaring the DocType. Any suggestions to fix this. Also on an off-note: is there any better IDE's to code ASP.NET?
<%# Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>Hello VS2010</title>
</head>
<body>
<asp:content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<form id="form1" runat="server">
<div>
<asp:Literal ID="Literal1" runat="server">
Hello World
</asp:Literal>
</div>
</form>
</asp:content>
</body>
</html>
Master Page
<%# Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form runat="server">
<div class="page">
<div class="header">
<div class="title">
<h1>
My ASP.NET Application
</h1>
</div>
<div class="loginDisplay">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<AnonymousTemplate>
[ Log In ]
</AnonymousTemplate>
<LoggedInTemplate>
Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
[ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/"/> ]
</LoggedInTemplate>
</asp:LoginView>
</div>
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
</Items>
</asp:Menu>
</div>
</div>
<div class="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</div>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
</body>
</html>
Master pages are a kind of template applied to all of your pages. Here it seems you use one without knowing it
MasterPageFile="~/Site.master"
In the masterPage you have all the content you want to be common to all your pages and a asp:content region where you can add content for each page.
So here you can try to remove the masterPage reference or just Adding and removing things in the asp:content region.
Here's the msdn link about MasterPages. I think it really necessary to understand masterPages to learn asp.net.
New Reply:
Well, okay.
So first things first only one form tag per page, that includes pages within master pages.
You don't need the form tag or the html, body or head tag on your Web form, only your master page.
So Page.aspx code should be like: http://codepaste.net/87n474
Note you need to include all content areas in your aspx page that are available in your master page.
Original Reply:
Couple of things.
Check your masterpage layout and see if there is any content misplace in that. (paste it here as well)
Also related to your masterpage, I don't see much point in having a masterpage if you're putting all your HTML markup inside the asp.aspx page.
Your doctype should be:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Note the small differences in capitalisation.
Finally, the only IDE any better than web dev express is the full version of Visual Studio, there isn't any better version for creating and debugging asp.net sites than the latest version of visual studio.
I’m playing with implicit localization on my Win7 box via VS2010 and something doesn’t quite seem right. I have a trivial page where I set the resourceKey of my GO Button to “bnGO”:
<%# Page Language="VB" culture="auto" meta:resourcekey="PageResource1" uiculture="es" %>
<!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>Test Implicit Localization</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="bnGO" runat="server" meta:resourcekey="bnGO" />
</form>
</body>
</html>
Then I have both testForm.aspx.resx and testForm.es.aspx.resx files that set the value of bnGO.Text appropriately:
When I run the application, the GO Button displays the "Go Forth!" text defined in the default testForm.aspx.resx even though testForm.aspx has uiculture set to “es” (which I think is Spanish).
What am I doing wrong?
The name of the file should be:
testForm.aspx.es.resx
Not
testForm.es.aspx.resx
I have a fully HTML project, with complete .CSS file.
The thing is I want to add some asp.net controls like TextBox's and Buttons and what not, but when I add server side controls to it and run the pages it gave me errors I cannot follow because it appears on the tab of the browser.
The error start with control 'txt' of type TextBox..., and then it gives me Navigation Cancelled, and the browser direct me to
http://youtubedownloader.mybrowserbar.com/cgi/errors.cgi?q=http://localhost:55942/Dar%2520Al-Thaqafah/Default2.aspx&type=dns&ISN=A9B31DEE919345BE838EAF628EAFA22F&ccv=149&cnid=937811&cco=US&ct=1&sc=500
Here is the code of default2.aspx page
[%# Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %]
[div class="header"]
[div class="logo"></div]
[div id="menu"]
[ul]
[li class="selected"][a href="Default.aspx"]Home[/a][/li]
[li][a href="Default2.aspx"]Available Books[/a][/li]
[li][a href="Default3.aspx"]Register[/a][/li]
[li][a href="Default4.aspx"]Checkout[/a][/li]
[li][asp:TextBox ID="txt" runat="server"][/asp:TextBox][/li]
[li][asp:Button ID="btn" Text="hhhhh" runat="server" /][/li]
[/ul]
[/div]
[/div]
[/div]
I am using Browser IE version 9.
Visual Studio 2005.
Thank you
Try with the code given below:
<%# Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div class="logo"></div>
<div id="menu">
<ul>
<li class="selected">Home</li>
<li>Available Books</li>
<li>Register</li>
<li>Checkout</li>
<li><asp:TextBox ID="txt" runat="server"></asp:TextBox></li>
<li><asp:Button ID="btn" Text="hhhhh" runat="server" /></li>
</ul>
</div>
</form>
</body>
</html>
Well with the limited information you provided, I guess the problem is that you are adding ASP.NET controls to an HTML page and not an ASP.NET page and that's why you see the errors. The ASP.NET controls are executed by the server and converted into Browser-readable HTML controls. So, you can only add ASP.NET controls to only ASP.NET page.
For a company we are making 2 different sites, now one of those sites got an flv player in it and streams local flv files to the clients with the webpart from: http://www.aspnetflashvideo.com
Now on the second site we also want an flv player but this one without local files, it should stream the flv file from the other website to the users of this second website.
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%# Register Assembly="ASPNetFlashVideo.NET3" Namespace="ASPNetFlashVideo" TagPrefix="ASPNetFlashVideo" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ASPNetFlashVideo:FlashVideo ID="FlashVideo1" runat="server"
VideoURL="http://flv.dumpert.nl/7649709f_YTDL_1.flv.flv" >
</ASPNetFlashVideo:FlashVideo>
</div>
</form>
</body>
</html>
Is this possible and how? Because it doesn't seem to work with the webpart.
I may be completely off track here, but it looks like your Video Url has the file extension in twice... Try:
<ASPNetFlashVideo:FlashVideo ID="FlashVideo1" runat="server"
VideoURL="http://flv.dumpert.nl/7649709f_YTDL_1.flv" >
</ASPNetFlashVideo:FlashVideo>
i'm creating a brand new masterpage with VS2010 Beta 2 and I get this warning (that causes me errors in the content pages):
Validation (XHTML 1.0 Transitional):
Content is not supported outside
'script' or 'asp:content' regions.
The masterpage's code :
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Bob.master.cs" Inherits="TShirtFactory.Web.All.Core.lib.masterpage.Bob" %>
<!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></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
As you can see, it's the default masterpage generated code. I get the warning when I hover the tag at top. Does anybody have an idea of what's going on ?
Thank you
In my case the error has gone after removing masterPageFile attribute from the Page-section in the web.config file:
<configuration>
<system.web>
<pages styleSheetTheme="mystyle" masterPageFile="~/myMaster.master" />
</system.web>
</configuration>
Or, if you need this attribute in the web.config file, just add empty MasterPageFile to you master page:
<%# Master Language="VB" AutoEventWireup="false" CodeFile="mySecondMaster.master.vb" Inherits="mySecondMaster" MasterPageFile="" %>
It's simple... Visual Studio is bonkers. Actually, the truth is that it can't possibly validate some markup simply because much of it is dynamic. For instance, in my project I have a constant warning about the lack of a <title> tag because it's added dynamically. Bottom line: the XHTML validator does not really know much about ASP.NET code.