Reputation: 676
Okay, so I've got this website and I've got several arrays that are declared in the code behind. I'm trying to use them on the aspx page, but it tells me that they are inaccessible once I get down to a second level div element. See code:
Code behind:
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();
}
}
And here's the 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>
So it tells me that strTitle
, strCity
and strCountry
are inaccessible due to its protection level, but strFilePath
is cool. I have a feeling that it is because of the class property of the div element. If that is so, is there a way to get around that? I tried using "this", but that didn't work either.
Upvotes: 0
Views: 92
Reputation: 16464
Need to make the variables protected so they can be seen in your page. They are private by default. The strFilePath isn't cool either, but is likely being ignored.
protected string[] strFilePath = new string[5];
protected string[] strTitle = new string[5];
protected string[] strCity = new string[5];
protected string[] strCountry = new string[5];
Upvotes: 2