简体   繁体   中英

How do you link an ASPX file to a different html file in Visual Studio?

I am confused, how would I be able to link an ASPX file in Visual Studio from a different folder within the solution? So I have the Solution for my web ASPX site, and I have another folder that contains all of my html/css/javascript/images. How would I communicate between the two and have an HTML page link to the ASPX site?

I know the code should be: View Reports right?

You as a genreal rule need/want/should/will palce those aspx pages in your current project folder. The reason of course is that "folder" becomes the root folder of the web site when you publish.

so, if you have some other aspx pages that you want to use? then from vs choose add->existing item, and then you can browse to that aspx page. This is really a SIMPLE IMPORT of that page into the current project.

So, the web pages and folders MUST exist in your current project, and you are NOT free to reference or use or have aspx pages outside of your current project. The web site layout will not work correclty.

Now, you can ceratinly refernce other projects "code" and things like other libraries of code. But a aspx web page is going to be converted to standard HTML for a browser, and those aspx pages will become the url of the web site, and thus all such pages must be in the root of the project, or in sub folders of that root project.

So, you might have:

  Welcome.aspx

but, you can say add a new folder to this project, and maybe call it

 SiteAdmin

So, now, you can place aspx pages in that folder, and your URL will become:

http:mycoolebsite/SiteAdmin/Manage.aspx

so, yes, all aspx pages have to be part of the starting folder for the web site.

it not at all clear what you mean by "link".

I mean, one can have page1.aspx, and then page2.aspx.

you can the drop a button in page 1, and when you click on it, it jumps to page2. This would not really be called "linking", but navagation to another page.

You can thus of course add a hyper-link in page one. or you can drop in a button, and with some code jump/navigate to that page2.aspx.

So, assuming I have page1.aspx, and page2.aspx, then you are free to drop in a button, say like this:

   <asp:Button ID="Button1" runat="server" Text="Jump to page2.aspx"
     OnClick="Button1_Click" />

And code behind could be this:

Protected Sub Button1_Click(sender As Object, e As EventArgs)

    Response.Redirect("~/page2.aspx")

End Sub

But, you don't have to use code behind, and you can say drop in a hyperlink control, and do this without code.

eg:

   <asp:HyperLink ID="HyperLink1" runat="server"
   NavigateUrl="~/About.aspx">HyperLink</asp:HyperLink>

So, you can jump/navagate from a html page to a aspx page by using a hyperlink.

If this is a html page, then use a html control, not a asp.net one, and thus use:

<a href="About.aspx">About our site</a>

So, you can use a plain jane hyper link, and use one in a aspx page, or a html page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM