Hi there, I'm trying to design some forum software and I'd really like to use the conversation-style view that Code Project uses, rather than the more main stream thread style (I hesitate to use traditional here as I believe the conversation view came first?). I'm struggling with how you would pull out the messages to view on any given page without a whole load of unnecessary iteration and database queries. So you have thread topics, each represented by a message with child messages (presumably theres no need for a thread topic DB table, a message with no parent would signify this). You want to keep the order of threads according to the original post date, but how do you then select the right number of threads and messages to fill a page (say 30 messages max) without knowing exactly how many messages each thread will contain? Now I'm thinking about it I guess the easy answer is to keep a count! Surely there must be another solution that could be calculated on the fly, preferably inside some SQL statement. Well, I don't think I've really explained that very well but hopefully someone will get my gist! Basically I want to build a forum that works the same as these ones do, think about that for a minute and you should either understand my problem or realise theres no problem at all and you have the answer for me :D I seem to remember reading ages ago that the original source code for the Code Project forums was available some where, is that still the case? If so where? Cheers! -- Rory
badgrs
Posts
-
Algorithm/SQL that Code Project uses to select forum messages -
Jumping to dynamically created named anchors in IE (JavaScript)I managed to reproduce this and have no idea why it doesn't work, theres obviously something fishy going on (well, it is IE after all). To get it to work I had to set the ID of the anchor instead.
a.id = "my_anchor";
-
javascript form.reset() issue after the postback of an asp.net pageIt resets your values after the postback since the html returned has value="your value" for each field, so the reset uses these values (which are empty on the first request)...but anyway you already got that far. Why are you using javascript for the reset in the first place? Why not use ? Since the values are 'hard-coded' (in the html) upon a postback, javascript is your only option. Heres a simple function that should work:
function ResetForm() { var inputs = document.getElementsByTagName("input"); for(var i = 0; i < inputs.length; i++) { inputs[i].value = ""; } }
I haven't tested the function and it will only reset input elements (ie not select). -
invoke a severside code when clicking browser close butonSince your so adamant about it I had a little play around and I'm going to have to eat my words and say I'm wrong :-O I guess I didn't really give it much thought in the first place, just wanted to point out to the OP that javascript can't be relied upon....it seems we both know all about that though so no point in arguing technicalities.
-
invoke a severside code when clicking browser close butonI'll have to go back on what I said as closing the browser will run the code, but there are lots of cases where it won't. For instance, using the browsers back and forward buttons don't cause unload events (so if a user goes back a few pages before closing it won't run.....I don't think....), if the user has disconnected from tinternet, if the browser crashes, if you force quit the browser... It also depends on the browser, certainly IE has different ideas about when to call load events than Firefox. I'm not saying you can't use this method I'm just pointing out that it can't be 100% relied on (as anything client-side can't be)
-
invoke a severside code when clicking browser close butonAjax is simply a technique that you achieve using Javascript. For what you want you'd need to hook into the body's onunload event and fire a quick request to the server. Of course there is no guarantee that this will ever run, and I'm pretty sure the browser close event is one situation that it won't. Best not to rely on it.
-
include fileSebastian T Xavier wrote:
which contains some global variables and enumerations
Technically there is no such thing as a global variable in .NET - it is Object Oriented and you would do good to go research what OOP is before embarking on an ASP.NET application, especially if your coming from a classic ASP background (which it sounds like you are). Assuming by global you mean you've declared a variable like: (I realise you're probably working in VB.NET but I don't do VB.NET, it sucks)
public class MyGlobals { public static readonly string MY_GLOBAL_VAR = "some value"; }
To then use this you would simply have to import the namespace with ausing
statement (if the class is inside another namespace) and reference the variable like:MyGlobals.MY_GLOBAL_VAR;
-
include fileInclude what type of file and where?
-
goto top...?For the top link, add a link to the top of the page, usually around the header, like your header (it doesn't have to have test, just be at the top of the page) and then your top link will look like: top^. To show description you will need to set style initially with display:none and then add an onclick handler to the "concept -" links that will toggle the display property to :block. There are plenty of handy scripts to do this, google it.
-
Publishing website problem ...If you're question was not answered 3hrs and 20mins ago what makes you think it will be answered now?
-
iI can't see any way to get past the first page. The error has nothing to do with the details you enter, its a problem with the SQL Server connection your application is trying to open (as is evident from the error message)
-
Interface irritationWell, the simple answer is not to use tables for layout, in case you hadn't heard there a bit antiquated - check out CSS (although I won't lie about its learning curve). However, select elements aren't block level elements so I don't see why they would force a new line. There is obviously something else going on that you're not aware of, have a look at the generated markup to see whats there, and if the width you set for the column is getting set correctly.
-
Reader Plugin LayeringI'm pretty sure that you can't embed PDF fies in a web page, they can only be opened on their own. So, Acrobat will always take over the page and open the PDF document.
-
Reg:Using .htaccess fileAs far as I know .htaccess files are only for Apache web server (and some others like it), not IIS. You can use URL rewriting, either through IIS or your own HTTP Module but I don't know any specifics.
-
simple,short questionI'm pretty sure they don't necessarily have to be, thats just the way VS adds them in, no reason they couldn't be public (they can't be private as the page that ends up as a subclass of your code-behind has to access them).
-
An extender can't be in a different UpdatePanel than the control it extendsIts pretty self explanatory - you've put an extender control on your page that extends a control within a different updatepanel. This is a restriction of the extender framework (unfortunately, I've come across troubles with it before), an extender MUST be inside the same updatepanel as the control it 'extends'.
-
Function doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used.Why not just add the
Return _dt
to the end of the function, so if theres an exception you'll return an empty datatable rather than null. That would seem more logical to me. -
Creating / Running a seperate aspx instance/application on the server.If you can run another web application then you can make a request to that from your code just as a use does. The System.Net.WebRequest (I think thats it) is probably your best bet, just give it the Url and params and it'll get you the response. Thats the simple solution, to return a JSON string or CSV-like data from either an aspx page or a web service (ascx file), as if the code is a client browser making an Ajax request. Slightly more work but a better solution would be a 'proper' web service, where the calling code (inside Sharepoint) has a reference to the web service and uses it like any other class, no idea if you can do that with Sharepoint though but if you can there are tonnes of tutorials on web services out there.
-
Why SelectedIndexChanged doesn't fire ?Not with just that code no. Perhaps your not actually changing a value? Is it set to autopostback? How do you know its not firing if theres no code in there? (or was that just for posting purposes?)
-
Function doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used.Its pretty self-explanatory really, not all code paths inside that function will return a value. Your return statement is inside a try block, if that block throws an exception the return statement will never be reached. Its generally bad practice to put return statements half way through methods anyway, can cause maintenance nightmares. Also I don't think your finally code will ever run unless an exception is thrown. Put the return statement right at the end of the function.