好的,所以我有了這個網站,並且我已經在代碼中聲明瞭幾個數組。我試圖在aspx頁面上使用它們,但它告訴我,一旦深入到二級div元素,他們無法訪問。見代碼:由於保護級別,無法訪問頁面字段
後面的代碼:
string[] strFilePath = new string[5];
string[] strTitle = new string[5];
string[] strCity = new string[5];
string[] strCountry = new string[5];
protected void Page_Load(object sender, EventArgs e)
{
string constr =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\TravelJoansDB.mdb;";
string cmdstr = "SELECT TOP 5 * FROM Table2 ORDER BY TravelDate";
OleDbConnection con = new OleDbConnection(constr);
OleDbCommand com = new OleDbCommand(cmdstr, con);
con.Open();
OleDbDataReader reader = com.ExecuteReader();
for (int i = 0; i < 5; i++)
{
reader.Read();
strFilePath[i] = reader[2].ToString();
strTitle[i] = reader[6].ToString();
strCity[i] = reader[7].ToString();
strCountry[i] = reader[8].ToString();
}
}
而這裏的ASP:
<a href="BlogPosts.aspx" id="iview">
<!-- Slide 1 -->
<div data-iview:image="placeImages/" + <%= strFilePath[0] %>>
<!-- Caption 1 -->
<div class="iview-caption" data-x="400" data-y="400"
data-transition="wipeRight" data-speed="700">
<h3><%= strTitle[0] %></h3>
<%= strCity[0] %>, <%= strCountry[0] %>
</div>
</div>
所以它告訴我,strTitle
,strCity
和strCountry
無法訪問由於其保護級別,但strFilePath
是涼。我有一種感覺,那是因爲div元素的類屬性。如果是這樣,是否有辦法解決這個問題?我嘗試使用「這個」,但那也沒用。
div的CSS類對代碼後面的變量範圍沒有影響。 – mason
很高興知道。對我的問題有任何想法? – Joseph
你不能在ASPX頁面''data-iview:image =「placeImages /」+ <%= strFilePath [0]%>'上連接這樣的字符串。 – mason