Label Text Disappears on PostBack

J

Jason Sirota

I created a custom "page numbers" control, which displays page numbers on my listing page. My problem is that at the end of the page numbers I set a LinkButton for "Next Page" with a " : " inbetween the final page number and the link button arrow. I then enclose that LinkButton in a Label to turn it on and off based on whether the page the user is viewing is the last page (i.e. if the current page = last page, don't show) Here is the HTML

<asp:Label Runat="server" ID="lbl_nextpage" Visible="<%# Not(int_currentpage = int_totalpages) %>" >&nbsp;:&nbsp
<asp:LinkButton Runat="server" ID="NextPage"><img src="<%# str_imageroot %>/arrow.gif" width="4" height="8" border="0" alt="next page"></asp:LinkButton></asp:Label

My problem is this. When I start on Page 1, the Label appears as it should, if I then jump to the last page, the Label disappears as it should. However, if I go back to another page, the Label reappears (i.e. it inserts a span tag) but the span tag is empty, neither the Link Button nor the &nbsp;&nbsp; is inside the <span> tags.

I checked all my databindings, all the controls are visible at render time, yet the <span> tags are empty. I have used this method hundreds of times with no problem, the controls switch on and off. In fact, the code is exactly the same in the "previous page" section and that link button turns on and off without a problem

I am stumped
Jaso
 
J

Jason

I figured out the answer to my own question

As it turns out, the problem was the literal control &nbsp;:&nbsp; after the label. It seems like if the first control is literal, this problem happens. I enclosed the literal in another label control and voila, it worked perfectly, any idea why this happens?
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top