Select all the text you want to do this with and bring up the Tabs dialog (Type Menu–>Tabs). Now, insert a right tab on the right hand side of the tab ruler (you can adjust its position later if necessary). The "right tab" is the third tab marker from the left. Once you have inserted the tab on the ruler, highlight the tab. Now, above the ruler, see the box that says "Leader"? You want to put a "." character in that box. So, type the "." and hit "enter" on the keyboard. You just have to enter one period symbol and this creates the ...... line you are looking for. Now, go back to the text box where you started and if you don't already have tabs inserted into your text, you can type them in. You should end up with your Table of Contents entries, a tab in which you now have a dotted line (created by the leader character you entered), and then you can fill in the page number. Since you used the "right tab", they will appear to be justified/lined up on the right hand side of the numbers. Just FYI, you could also use the "left tab" to do the same setup and the page numbers would line up on the left side and have a "ragged right" appearance.
I can think of at least two ways to deal with this, and hitting Tab by itself if you want the tab number to float with the width of the text frame isn't in either one.
Instead of an ordinary tab (left, center, right, or character -aligned and set in the tabs panel or as part of a style) you need a Right-Indent Tab. You type that by hitting Shift + Tab.
That leaves the dots, and how to make them. These are called a "leader" and you can set a character or sevral characters (like a space followed by a period to put some distance between the dots) to act as the leader for any ordinary tab you set, but you can't set a leader directly for right-indent tabs, so there are two choices. The first is to include a tab stop in the paragraph style definition you have applied to the text and add the leader to that. This tab stop can be anywhere, in or outside of the column bounds, as long as it is the last tab stop on the ruler. It should probably be set beyond anywhere you would otherwise want a tab position so it never gets used when you hit the Tab key.
The other method is to use a custom underline set to a dotted or dased stroke style. I prefer this method myself as you can adjust the weight and postioning of the underline. I'm partial to the "japanese dots" stroke style for this. This is best used as a character style that you apply to the right-indent tab as a nested style in your paragraph style defintion: apply [None] up to 1 Right-Indent Tab, then your underline style through 1 Right-Indent Tab. You can pick the right-indent tab from the list of special characters in the dialog.
Now, more to the point, why are you typing page numbers into a TOC at all? ID has a very nice automatic TOC feature that works by finding specified paragraph styles.
Just chiming in to cast another vote for using the InDesign method of automatinc TOCs. By taking advantage of that feature along with some planning and nested styles, you can build a perfect, styled TOC in no time. It does require that you are scrupulous with styling the headings that will end up as TOC listings, but hey, that's a good idea anyway. Before I learned the TOC trick, I would have to scroll back and forth to the pages of longer documents to check on the page numbers. More than once I screwed that up. This is dead on every time. Give it a shot!