-1
解決路徑我有一個用戶控件名稱「新聞」,這是裏面的「用戶控件」文件夾看起來像用戶控件/新聞和代碼是在這裏如何在ASP.NET
<%@ Import Namespace="System.Data" %>
<div id="news">
<% string getLatestNews = "SELECT * FROM pages WHERE show='True' Order By Date DESC";
DataSet latestNews = new DataSet();
latestNews = sage.connectionhandler.ExecuteFetch(getLatestNews);
int cnt = 1;
foreach(DataRow dr in latestNews.Tables[0].Rows)
{
string NewsId=dr["pageid"].ToString();
string NewsTitle=dr["Title"].ToString();
if (NewsTitle.Count() >= 100)
{
NewsTitle = NewsTitle.Substring(0, 100);
}
cnt=cnt+1;
%>
<div class="inside-news" >
<a id="news1" href='../pages/news.aspx?id=<%=NewsId %>'>
<%=NewsTitle %></a>
</div>
<% if (cnt >5)
break;
} %>
目前我在這裏美國/市場/商品/頁/的Index.aspx
當我點擊每個新聞標題在鏈接US/market/commodities/pages/index.aspx page然後新聞鏈接進入「US/market/commodities/pages/news.aspx?id = 10」根目錄「pages/news.aspx?id = 10「
那麼如何解決上述路徑問題呢?
用戶'Page.ResolveUrl'它解決烏爾問題 –
的問題是,在這裏,我想'HREF = '.. /頁/ news.aspx?ID = <%=NewsId %>''檢查鏈接,我想它會像'href ='../../pages/news.aspx?id= <%=NewsId %>'' –
你想要這樣,yoursitename/pages/news.aspx?id = 10? –