Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

PageList with Paging - great but I want to exclude symbols

Vote:
 

Hi all!

I'am experimenting with some easy to use front end code - PageList and some attributes like Paging. I would like to thank Frederik Vig for his great guide.

Now, I have a "paging" on a site and it displays 1 2 3 > » , it renders with css classes for selected and unselected and I can design them, it works well. But! I want to exclude > ».

Is there an easy way to do it? I dont feel absolut confiedent with code behind but in worst case maybe I can manage. But please try to explain well. The CodeBehind document is "blank", I mean only namespaces a class and the PageLoad method(?).


Many thanks!

#55262
Nov 24, 2011 9:46
Vote:
 

Hi again! I did this in the Code Behind, it seams to work. But what did I do?

Overide overides the functionality of the paging in the repeater 'inventarielista', yes? The method, is it neccesarry to name it OnLoad? What are the parameters? What does base.OnLoad(e) do (without it the page layout gets messed up)?

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            Inventarielista.PagingControl.NextPagingItemText = "";
            Inventarielista.PagingControl.PrevPagingItemText = "";
           
        }

    

#55270
Nov 24, 2011 12:03
Vote:
 

OnLoad is a special method in ASP.NET web forms, and a very important one. Take a look at this article for some more background on the ASP.NET Page Life Cycle.

In you code, what you're doing is setting the text for the NextPagingItemText and PrevPagingItemText properties to be empty. This is not necessarily that good.

Could you perhaps explain some more what you're trying to achieve?

Frederik

#55283
Nov 25, 2011 10:13
Vote:
 

I want to get rid of > in the pager, plain and simple. =)  Why is it not good? Is there another way?

#55292
Nov 25, 2011 18:50
Vote:
 

If this is because you´re going to style it with CSS instead I would have text there for screen readers to read, and hide it with CSS instead (text-indent, position: absolute or similar).

Frederik

#55294
Nov 26, 2011 13:15
Vote:
 

Yes I'am going to style it with CSS, but only the numbers. I want to get rid of the arrows. Eh, I dont know how to do it with css since there are only two classes by default: "SelectedPagingItem" and "UnSelectedPagingItem"(?), and the IDs do change yes(?), so if I hide them with css it would also hide the numbers.

I respect the accessebilities concern, absolutly, but the screen readers will read the numbers, yes? So I really dont see a problem. Or am I missing something? Visually and "semantic" you navigate with the numbers. I dont want the arrows there, period. =)

Also, regarding the C#, thank you for the link, it is complicated however, but I will take my time and read it. I find it more easy however when I can ask questions to someone with knowledge. I'am trying hard to understand what it is I have done.

I have an EpiServer:PageList with the ID 'inventarielista' with the pagelink property set to 'PageLink'. I understand how the repeater works (basicly) and how it lists the children. But regarding the C# in the codebehind (see below):

* 'OnLoad' is a method, yes. Just very briefly, what is so special about it? The Page object calls the method? The method is run automatic?

* In the code behind file there is another method named 'Page_Load', is it also a special method? Run automatic?

* For the two above to be "special" autoeventwireup has to be set to true in the page template, yes?

* 'Protected' means the method can only be called in this class? But page can call it somehow?

* Overide means it will overide things in the repeater? Is 'overide' neccesarry since I dont specify paging with attribute in the front code? What is there to overide?

* (EventArgs e), e is a parameter, a local variable, of the type EventArgs? Page puts something there when the method is run?

* What is 'base.OnLoad(e)'? base calls this method? Its a bit confusing (as always). =)

 

        protected override void OnLoad(EventArgs e)
        { 
                base.OnLoad(e);

                Inventarielista.Paging = true;
                Inventarielista.PagesPerPagingItem = 1;
                Inventarielista.PagingControl.CurrentPagingItemIndex = 0;
                Inventarielista.PagingControl.NextPagingItemText = "";
                Inventarielista.PagingControl.PrevPagingItemText = "";
        }
#55303
Nov 28, 2011 8:50
Vote:
 

The ASP.NET Life cycle is hard to get your head around at first, but continue reading and working with it and you'll understand more and more :).

The OnLoad method and the Page_Load methods are special methods that get run as part of the pages life cycle (you also have OnInit, PreRender etc), this allows you to change and add logic where needed.

So for OnLoad you're overriding an inherited method from the Page base class. Page_Load does the same, but with a little different syntax. For Page_Load to work, you need to have AutoEventWireup set to true. ASP.NET then uses reflection to check your code-behind for these special methods (Page_Load etc). For this reason it's recommended to not use Page_Load, but instead use OnLoad, like you've done, and set AutoEventWireup="false" (reflection is quite expensive).

If you right-click the TemplatePage in your code-behind in Visual Studio (the class you're inheriting from) and choose "go to declaration" you'll be taken to that class, you'll see that it inherits from EditPage, SimplePage, PageBase (all special EPiServer classes that are good to know about), PageBase inherits from ASP.NET Page class which defines all the events.

I would take a look at the official ASP.NET website, they have a great learning section with videos, articles and tutorials, that explain this much better and give you some extra detail :).

Good luck!

Frederik

#55346
Nov 29, 2011 12:04
Vote:
 

Ok, I understand it a bit better now. And yes I will read up on it during the hollidays. I'am learning more and more, albeit at a quit slow pace.

Thank you very much. Have a nice day!

#55348
Nov 29, 2011 12:15
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.