Reference code-behind variable

A

Anthony Bollinger

I am still getting up to speed with ASP.NET 2.0 and its companions (VS, VB,
etc.). I am successfully using a PagedDataSource in my code-behind module,
but I need to reference the PageCount on the page itself to generate links
for the pages. I have tried a few things, but I am still limited to
old-style (one file) thinking. How can I do this without bringing all my
code into the page?

Many thanks,
Tony
 
J

JF

Hi Tony!

Whether you use Code Behind or not should not change anything, unless I
do not undertsand your problem. Even if the code is in two files:
filename.aspx and filename.aspx.vb, you can still do things as if they
were in one file.

For example, you can do this in the VB file:

Dim a As String
a = "Hello World!"

And then in the aspx page, use:

<%=a%>

to output a's value.

Cheers!

JF
 
A

Anthony Bollinger

Thank you for replying. I need one more piece of information. I have a sub
that is called in both Page_Load and each time a navigation button is hit.
It has the following declaration:

Dim PagedData As New PagedDataSource

So, the CurrentPage is stored in the ViewState, but the PagedDataSource is
created each time this sub is called. That is the code I picked up from an
article on the web on paging. I think if I pull this declaration out of the
sub to make it global to the class, it may wreck the code. Right?

In this scenario, how do I reference the PageCount of the PagedDataSource in
the HTML page?

Many thanks,
Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top