Why Use Url.Content For Referencing Resources
Dec 10, 2010
In almost every ASP.NET MVC example I've come across, I always see Url.Content being used to reference CSS, JavaScript, and Images. Not once has anyone explained WHY to use it.
What's so bad about doing:
<img src="/Content/Img/MyImage.png" alt="My Image" />
<script src="/Scripts/jquery.js" type="text/javascript"></script>
<link href="/Content/Css/Default.css" rel="stylesheet" type="text/css" media="all" />
View 1 Replies
Similar Messages:
Mar 19, 2011
I have a Master Page that contains a Menu Control. Each menu item clicked is supposed to load a new aspx page. My problem is (since I'm new to Master Pages) actually loading a Content Page. This is what my MP code looks like and it's only just a snippet. The first set of code are the ContentPlaceHolders in my MP. The second set is the code in my code-behind file in my MP. Hope this makes sense. In the VB code, all I'm trying to do is load my Customer.aspx page. What am I missing?
HTML Code:
<asp:ContentPlaceholder ID="Welcome" runat="server"></asp:ContentPlaceholder>
<asp:ContentPlaceHolder ID="MainArea" runat="server"></asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="CustContent" runat="server"></asp:ContentPlaceHolder>
Code:
Private Sub Menu1_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles Menu1.MenuItemClick
Try
Select Case e.Item.Value
Case "mnuCustomerMaintenance"
MainArea.Page = Customer
End Select
Catch ex As Exception
End Try
End Sub
View 11 Replies
Apr 6, 2010
we just started using Master Pages for our website and are having a problem referencing a control outside of our formview.
This label is located on the content section:
[Code]....
How to we reference this label accordingly?
View 2 Replies
Mar 8, 2011
Under Visual Studio 2010, I'm developing an asp.net application. I added a folder to my project called Flash. Under Flash folder I added a swf file with its external resources to run.
The folder content:
1- ScrollingImages.swf file to lunch the flash
2- ScrollingImages.xml file that the swf file uses to read images from thumbnails folder
3-thumbnails folder which content images used by swf file. I can embed the swf file to html easily using this code:
[Code]....
But when I use the same code to embed it to asp.net page I will have a problem that the flash will run but I cannot see the images so the swf file unable to locate the xml file and the folder of the images location and they all in the same folder.Here is the code I used in the aspx.net content page.
[Code]....
I also tested it in aspx.net page and I'm getting same result no images appear. I know that the problem is related to who to embed the swf external resources (the xml file and the images folder) to the aspx.net page but I searched a lot and I could solve it.
View 1 Replies
Apr 20, 2010
I was just wondering guys, how did you manage to update website's content with resx(resources) files.Did you manage user's database with connection, accessing to this page. I need to make a poll as well, should I use sharepoint or c# with a database?
View 1 Replies
Feb 3, 2011
I have recently upgraded to VS 2010 and converted my web site into a web application. Now, when I attempt to build, I receive the error:
Resource name '<name>.Resources.resources' cannot be used more than once.
There is no page name or anything, and I have completely exhausted all that Google has to offer.
View 2 Replies
Jun 9, 2010
I have to create a framework 4.0 website, is it possible to reference a dll of the data layer( the data layer is an other project in framework 3.5) in my website? The main reason of this is I want to reuse the datalayer of the application which is very huge.
View 1 Replies
Feb 12, 2011
I am trying to use QueryStrings from my C# file in my ASPX file:
<asp:Button ID="LinkButtonDetails" runat="server" Text="DETAILS"
PostBackUrl='<%# string.Format("~/projectdetails.aspx?guid=<%= id%>
&name=<%= name%>
&role=<%= company_role%>
&member=<%= mem_id%>
&company={0}
&project={1}&id={2}", Eval("CompanyID"), Eval("ProjectName"), Eval("ProjectID")) %>' />
View 2 Replies
Jun 10, 2010
I have an IIS web site. This web site contains other web sites so the structure is like this.
[code]....
The problem is that it now tries to find the file at http:serverMainWebSiteScripts....
How can I work around that? Should I put all my scripts and CSS files into the root directory, is that a preferred solution?
View 3 Replies
Jul 27, 2010
Can I declare namespaces in the web.config so that I don't have to write using statements for each namespace in each of my codebehind files?
View 3 Replies
Jul 13, 2010
I keep trying to add an assembly reference to my website which doesn't show up anywhere in my code. Specifically, I would like to add a reference to System.Xml.Linq.dll to my website. No such reference appears in my web.config file. Also, when I right click on the website in the Solution Explorer window, go to Property Pages, and then click on References in the left-hand column, System.Xml.Linq does not appear. Yet, when I right-click on the website and go to add reference, I ultimately am met with the error:
"The website is already referencing the assembly 'System.Xml.Linq'"
Also, when I put a using statement at the top of one of my classes in my App_Code folder for the System.Xml.Linq namespace, the Visual Studio IDE does not flag it as an error.Any insight into this strangeness would be very much appreciated. I'd like to put this into production someday, and I'm worried it might not work due to a missing reference. The version I'm currently using is Visual Studio 2010 Professional Edition.
View 9 Replies
Nov 2, 2010
I have a label control on my MasterPage that is used to display error information. If an error occurs on another aspx page or a Module.vb page, how can I display the exception in the label control on my MasterPage? I tried using a Session variable, however, it would not work in my Module.vb code-behind file.
View 31 Replies
Apr 10, 2010
I have written a custom membership provider for my MVC 2 app, and it all works fine. I wanted to force people to log in as soon as they went to the site, so set the authorization section of the web config to deny annonymous users. As expected, when you try and access the site, it re-routes you straight to the LogOn.aspx page. The problem I'm having is that when it initially jumps to the LogOn page, it cannot find any of the files referenced in the html header section.
The strange thing is I set a path to a css file as follows:
../../Content/site.css
yet in the page it shows up as
../Content/site.css
I even wrote a html helper that uses Url.Content on the paths passed in, but this still does not solve the problem. If I go to the LogOn page after the application has initially loaded, it references all the files correctly.
View 1 Replies
Dec 13, 2010
How do you reference a LINQ object that you have created such as a list, in your HTML? I have seen examples of how to do this using MVC, but I am using Web Forms. Here is my LINQ :
[Code]....
And I want to be able to for example check if my linq returns any data and if so iterate through it using a foreach loop in my HTML. change my linq so that it returns a generic list rather than what it is doing at the moment.
View 4 Replies
Mar 23, 2010
I have a control that I use to populate a cascading menu with LinkButtons. All link buttons have the same OnClick event that I want to use to load content as well as change the clicked button's color to show the user which LinkButton they have selected.
My problem is that I don't know how to access any LinkButtons other than the one that is calling the OnClick event, so any colored button remains that color when other boxes are selected.
Is there any way I can reference all LinkButtons within a Panel to clear their colors so only the selected LinkButton is colored?
View 4 Replies
Feb 25, 2010
If statement referencing a Value in a Multidimensional Array
[Code]....
View 2 Replies
Jan 20, 2010
I have a utility project that has an "XML" folder with two XML files in it, this project is then referenced by an ASP.net web project. I was wondering do you have to set some sort of build option to place the folder in the BIN of the website, or is there another approach to referencing these two files from the web project?
View 1 Replies
May 26, 2010
I have a web site that is hosted by Network Solutions. The hosting package I have includes support for ASP. I can place a simple aspx page on my web site and point to it with my browser and it appears to execute. What I'd like to do is reference a text file (for parsing) that is in the same folder as the aspx file. I have no idea what the absolute path is to the folder. How can I reference the file for reading if I don't know the absolute path?
View 3 Replies
Feb 18, 2010
I thought this would be easy but i cant find what i am looking for online
I have 2 pages, the first 1 has a button that opens another page. On this 2nd page the user selects a picture. When the user selects a picture the form closes. When they select a picture i want the image control on the first page to change.
I'm not sure how to do this, i guess i could set the image path as a session variable and reload the first page but again i'm faced with the problem of how to reference the first page from the 2nd
View 3 Replies
Jan 29, 2011
My displaycloud.aspx page contains two databound data lists, each for displaying a tag cloud. The datalists have an EmptyDataTemplate that holds an empty label if nothing is retrieved from the db. I am trying to display the message 'Please Log a Story', by using the code below on the companyadmin page, but I am getting an error (the controls are not on the same page). How can I reference the labels positive_tags and negative_tags from displaycloud.aspx in companyadmin.aspx? Also, I want to redirect if the EmptyDataTemplate is not executed as shown at the very bottom of the page.displaycloud.aspx:
<EmptyDataTemplate>
<asp:Label ID="positive_tags" runat="server" Text=""></asp:Label>
</EmptyDataTemplate>
[code]...
View 1 Replies
Mar 17, 2010
Probably really easy but in my VB code I would like to say
If webpage = "ErrorPage" then
do seomthing
End if
So the thinking behind this is that if the ErrorPage is the open page on my site it feeds that into the webpage variable and then that runs the If statement.
View 1 Replies
Feb 14, 2013
I'm trying to set a value for an HTML Element within my code-behind. I need to set a <div> elements "display" property to "inline". The way I have it coded is like this:
Code:
divContact.Style("display") = "inline"
Is this the right syntax? I only ask because it doesn't seem to work but I don't get a run-time error when the statement is executes. ???
View 9 Replies
Jul 9, 2010
I have a gridview that has a hyperlink field in one of the columns. My question is how do I can I reference the the hyperlink's datatextfield when I click on the hyperlink? The field is a PDF that is stored in the data base and I need the datatextfield to reference the record in the db.
View 5 Replies
Aug 24, 2010
Does anyone know how to do this? I built a backend c# class in asp.net but want to access these same classes without recreating them in silverlight. Is this a possibility?
View 4 Replies
Jul 9, 2010
I'm displaying a table based on query results, and each record has a dynamically generated dropdownlist and submit button (and other controls, but this is simplified). That part works fine, but how do I reference the controls in a function? Here is the code I've tried. Create the controls:
[Code]....
Reference the control values (hopefully):
[Code]....
The function SubmitAction_Click fires when I click the Post button, so that part works. I just can't figure out how to reference the selected value of the dropdownlist. You can see that I'm explicitly giving the DDL a unique ID (DS_RecordID). I'm guessing I have to use FindControl to reference it, but I don't know how to format the code.
View 4 Replies