2016-12-19 7 views
0

私はWeb開発の初心者です。ハイパーリンクを使った簡単な前向きのナビゲーションが私のやりたいことです。メインページで簡単なウェブナビゲーションを作成するには?

私はこのような2番目のページへのリンクを持っている:

<a href="/development/html/test2.aspx">This is the LINK to the second page</a> 

してから、この2番目のページでは、私はこのようなメインページに戻って指すリンクがあります。

<a href="/development/html/test1.aspx">This is the LINK to the first page</a> 

2番目のページでこのリンクをクリックすると、メインページが見つかりません。私は次のエラーを取得する

<siteMapNode url="~/development/html/test1.aspx" title="test1" description="test1"> 

     <siteMapNode url="~/development/html/test2.aspx" title="test2" description="test2"> 
     <siteMapNode url="~/development/html/test1.aspx" title="test1" description="test1"/> 
     </siteMapNode> 

    </siteMapNode> 

:ここでは、サイトマップXMLで

Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /development/html/test1.aspx

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1586.0

+0

をあなたのメインページ上にある場合、どのようなURL

あなたのhrefにrunat = "サーバー" プロパティを与えますブラウザのアドレスバーが表示されますか? –

+0

あなたの 'href'と' siteMapNode'の 'url'属性の違いを見てください。 '〜'を参照してください。これは、ASP.NETを使用するときに重要なことです。これは、心配する必要がある「仮想パス」です。 –

+0

[asp.netパスでチルダ(〜)の使用可能な複製](http://stackoverflow.com/questions/3077558/use-of-tilde-in-asp-net-path) –

答えて

1

それはあなたのtest1.aspxのように見えると同じフォルダにtest2.aspxているので、私はあなたを思ういけませんあなたのフォルダをナビゲートする必要があります。あなたはResponse.Redirectを()を使用して試すことができます

<a href="test1.aspx">text</a> 

<a href="test2.aspx">text</a> 

編集

;:これを試してみてくださいこのように:

<a href="#" runat="server" onserverclick="goToSecondPage">This is the LINK to the second page</a> 

そして、あなたのC#であなたがして行うことができます:

protected void goToSecondPage(object sender, EventArgs e) 
    { 
     Response.Redirect("test2.aspx"); 
    } 
+0

それでも仕事....更新されたエラーメッセージを見てください – Ivan

関連する問題