I have a very strange problem with my website... I created a rather large page, consisting of a few tables with some labels and textboxes where the user can enter a mechanical car setup (it's for a racing game).
I was working with simple textboxes previously, but I recently switched over to a NumericBox control which should allow only numeric input using some client-side javascript. The NumericBox control is simply a UserControl with a single TextBox on it, and some client side events are added to this textbox which call methods from a single javascript file ("Scripts/numericValidator.js")
When I put a couple of these boxes on a page it works just fine, I can only enter numbers. For it to work though I need to add the script to the page and I do that using this line, either in the head content or in the body content controls:
(the path is chosen with the 'Pick URL' dialog so it should be alright, and it does indeed need to go up two directories first as the page is in the '~/Pages/RequireLogon" directory)
However, after replacing most of the textboxes on my large page with NumericBoxes, and adding this script line to my aspx code, the design view is 'broken'. I cannot see any of my controls anymore, and I cannot even put any new controls on there. It seems like the Content control is missing, even though it's still there just fine without errors in the aspx code.
When I remove the script line, the problem is fixed again, the controls re-appear. So it's definitely the script line causing the problem, but I cannot see how it could...
I tried it with a new blank page and the problem appears there too. If I use this simple page with just a button:
then the designer is broken. I cannot see the button and I cannot add any controls either. Remove the 'script' line from the head content and it works again.
Strange...? Or am I doing something completely wrong :/
I tried restarting visual studio, deleting bin/obj folders and restarting, restarting PC, nothing helps.
Just in case it's the javascript itself causing problems I attached it so you can see it (it's not mine I found it somewhere online), but I don't think the designer will execute javascript code?!
javascript Code:
// version: beta
// created: 2005-08-30
// updated: 2005-08-31
// mredkj.com
function extractNumber(obj, decimalPlaces, allowNegative)
{
var temp = obj.value;
// avoid changing things if already formatted correctly
Hmm.
Inexperienced with asp and master pages but 2 quick observations.
Can the script declaration be made outside the contentplaceholder?
Rather stupid question but, this is not your actually full directory? "../Scripts/numericValidator.js" (with the ".." )
That is indeed a strange one, you really aren't having much luck lately are you?
I have never seen a situation where including a script block has caused problems with the designer. It also seems like you have tried all the obvious suggestions. The one thing that I would be interested to see is the definition of the Master Page, i.e. where does that Content block go on the page. If you show the Master page definition, I will see if I can replicate the problem at this end, and we can work from there.
Even better, I created a completely brand new Web Application project, left everything default (I get a default master page, a Default.aspx page and some login stuff which I didn't use). I add the script to the Scripts directory. I reference it from the Default page, and boom, there it goes.
I attached the project files. I commented the offending script line (in Default.aspx), and in this way it works just fine, but as soon as I uncomment it and refresh the designer it breaks...
Let's see if it's just me.
Oh I'm using VS2010 by the way (and I suppose you'll need VS2010 to open this project).
Edit
Besides the problem in the designer it seems it is also broken during run-time. While the controls do show during run-time, it seems that they don't work at all. I can click buttons but there's not even a postback, just nothing happens.
Thanks, that is really strange but it does work. I thought <... /> was just shorthand notation for <..></..> and that it would always work but apparently there's something wrong here... A bug perhaps? Anyway, it works again, thanks for your help That's like the third time you've helped me out in a few weeks yet I still cannot rate you
You are correct, < /> should be the same as <></> but for some reason (which I still can't figure out) in this situation, it is not being respected. I tried looking for a stray opening or closing set of brackets that could be causing the problem, but I couldn't find anything. It could well be a bug, might be worth submitting to MS, as it is definitely a repeatable problem.
Not a problem about the rep, thanks for trying. You need to rep at least 10 other people I think before you can give rep to the same person again.