I have an ASP .NET composite server control that I've developed that uses a table as its base. It works correctly at run-time, but at design-time I get some flaky behavior. The first time the control renders on the design surface, everything looks good. But if I change any of the control's properties, then I just get an empty table. This control does not allow the page developer to add new rows--it is basically a positioning container used for a variety of other UI elements that get rendered together.
I set a breakpoint in the RenderContents method. The first line is a call to Me.EnsureChildControls, but CreateChildControls does not get called because Me.ChildControlsCreated is set to True. At runtime, this doesn't happen. The control renders correctly on every pass. At design-time, I have this problem every time the control refreshes itself after changing a property value.
To test, I created a simple TestTable and got similar results. Here's the source for that one:
Public Class TestTable
Protected Overrides Function SaveViewState() As Object
Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Protected Overrides Sub TrackViewState()
Protected Overrides Sub CreateChildControls()
Dim tr As New TableRow
Dim tc As New TableCell
Dim lbl As New Label
lbl.Text = "Test"
Protected Overrides Sub RenderContents(ByVal writer As System.Web.UI.HtmlTextWriter)
To run this test, just set your breakpoint on Me.EnsureChildControls. The first time the control is rendered in design view, ChildControlsCreated = False, and the CreateChildControls() method gets called. Change any property, and you'll break again; this time ChildControlsCreated will be True, and CreateChildControls() will not be called.
I could fix this in one of two ways that I know of: I could change the control so that it creates a DIV and creates the entire table on every postback; I could also modify RenderContents() as follows:
Protected Overrides Sub RenderContents(ByVal writer As System.Web.UI.HtmlTextWriter)
If Me.ChildControlsCreated And IsNothing(Me.Page.Session) Then
Me.ChildControlsCreated = False
This seems like a hack to me. I'm wondering if anyone else has any different ideas. Is there a reason why it might be a bad idea to inherit from table when I'm just using the table as a positioning element? Is there something else I could do in my code to cause it to recreate the child controls in design mode? If anyone has any better ideas, I'll update this post and properly credit you.
Thanks a lot!
Suggestion from your first code listing... change this line:
If (HttpContext.Current Is Nothing) Then
“You shouldn't be deriving from Table when you make a composite control. Derive from WebControl and contain a table.“
Both of which I sort of already thought, as stated in my original post just above the second code sample. Since what I was after at root was some validation that I was on the right track and wasn't overlooking anything obvious, I have to offer my thanks to Andy and Justin. Thanks guys!
I stated recently that I do some contract work in Linux from time to time, and that I had recently purchased Suse 9.1. The installation of Suse 9.1 went very well. The installation program (YaST) found my hardware, installed the appropriate drivers, found my internet connection, and had me up and running inside two hours. Once the basic installation was complete, I installed the development tools. Again, everything seemed fine.
Unfortunately, I have to use the vi editor to develop in Linux. It's not my choice, but basically a requirement of the project that I contribute to. It took awhile, but rooting around on the web led me to figure out how to edit vi's settings to have syntax highlighting for source code files. The default syntax highlighting was rather garish, so I just had to change it :).
One of the things I like to do is develop from my laptop. I recently installed a wireless LAN, so I'd like to develop via a telnet session. I have a favorite telnet program called Token that I use. This is when the problems began.
I found that I could telnet into my Linux station. No problem, I thought--I'll just install or start the service. I started the administration tools, found network services, found the telnet service, installed and started it. I found the ftp service as well, and knowing that I'd need that too, I went ahead and installed/started it. Click finish, and watch the magic of YaST create a new configuration file. While in the configuration utility, I found the place to install updates from the web. I figured “Now's as good a time as any,“ and let the auto-update run. I was liking this distribution more and more.
My internet connection had disappeared. Further, my samba client could no longer find my windows network. In fact, when I ran ifconfig (the Linux equivalent of IPConfig in Windows), I no longer had any ethernet service at all other than the local one. I restarted the network services, but still nothing.
I should say at this point that I wasn't too concerned. I didn't have a lot invested in this machine yet, so if I had to re-install and start over, it wasn't going to be a big deal. I tried searching the Suse support database, but first of all they don't have their support articles sorted by product. I couldn't find very much on 9.1--granted it's new, but I shouldn't be finding articles on Suse 7.1 while looking for articles on 9.1.
Before I did something as drastic as re-install my system, I wanted to check the users groups and see if I could find some help. I checked my newreader, and found alt.os.linux.suse . For those that are interested, this is my post to that group.
Let me say at the outset that I am not criticizing anyone that tried to help me. I don't think that anyone has a duty or obligation to help me solve my system problems, and I am grateful for any help that could be offered. That being said, the quality of the help that was offered was generally not that good. The first post in response to mine was someone else saying that they had had a similar problem. In fact, I found numerous threads in this newsgroup claiming problems with Suse 9.1 networking after running new services or upgrades from the web. At first the people that tried to help asked me to post the results of various Linux commands. I understood this approach--it's what I call “testing by the numbers.” After spending a lot of time on the phone with users of my own software, I know how important it is to establish a clear context from which to begin an investigation of a problem. So, even though I had already run through the obvious steps myself, I didn't mind recreating them for the other users that were trying to help me. Also, I am admittedly no Linux guru. I've never been impressed enough with the system to try to learn all of its ins and outs. So where I didn't understand what they were getting at, I deliberately showed my ignorance and/or asked questions. Otherwise, I answered their questions with as much detail as I possibly could. Once I'd gone that far, the help dried up completely. I checked the other threads that were similar to mine, and the same sort of thing happened. Apparently, even though I provided voluminous information about my system, setup, and steps I had taken, no one had any ideas. Again let me say that I am grateful for the help that was offered, and I don't think anyone had a duty to fix my system. It's just that all I've ever heard about Linux is “just get on the newsgroups and you'll find somebody that can help you.” Wrong.
After a week of searching for help, and finding only failure, I re-installed.
This isn't a criticism of the people in the newsgroups--it's just a statement that when something hairy goes wrong in a Linux system, you have little or no hope of finding good support for it. It may be different for individual software packages, but this is system level stuff we're talking about. When Microsoft is constantly criticized by Linux adherents for being buggy and unusable, I would expect better from a Linux software package. Not really of course: I've used several Linux distributions before this and have generally found them to be playing catch-up to Microsoft Windows; but if I, as a .NET developer, were to hold Linux to the same standards the Linux Community applies to Microsoft, then I would expect better.
As I said, I have side work to do in Linux. Suse 9.1 is supposed to be the latest and greatest. It is the greatest Linux that I've seen so far. Still, I'd rather be stuck in Windows 98 than be forced to use 9.1 as a primary PC.
On a personal note, I was never a huge Microsoft Windows fan until my job requirements led me to develop in Linux. It was after I started trying to write code in the system and encountering the anti-Microsoft bigots that I became a fan of Microsoft's. I can write code in C or C++ as well as the next guy. I can use pointers, create linked lists and trees, etc.. It's because I can do those things that I appreciate so fully what Microsoft has done with the .NET Framework. I can do those things, but it's a real PITA to do them!
I'm not against trying other operating systems and office applications. I personally do not like Mac's, but I have several friends that just love them. Their love of Mac's seems to be motivated by a genuine love of the computing experience, and less so by a blind hatred of Microsoft. I've used other office applications. The shared database aspect of Lotus Notes is quite impressive, but I find it severely lacking as an email client.
I'm starting a new chapter in my relationship with Suse 9.1 now. There's a chance that what happened was just some kind of fluke. I'll let you know if my impression gets better.
To all of you that work at Microsoft making the software that I love, especially those of you working on the .NET Framework and associated development tools, thank you.
Last night was fun. I'm sure I'm probably the last person on this blog to set up a wireless network, but on the off chance that there's still someone here who hasn't done it--”PEER PRESSURE!!!” Wireless networking is awesome!. I've got my new laptop running Windows XP Pro, and I relegated my desktop PC to a file and print server. I stole my KVM setup for my laptop, and use rdp services to get into my file/print server now. Sweet!
I also installed Suse Linux 9.1 on my spare PC last night. I've never been really impressed with Linux before (I had to work in it for a year and a half, so I do have user experience), but Suse 9.1 looks good so far. Of course, this is only the first night. I'll report back on what I find later. My first major task will be to set up some kind of rdp or vnc connection to the linux station as well. That way I can work with any of my three systems from anywhere in the house. If someone knows how to do that--well, my comments section is enabled <grin />.
Tonight I'll be coding from the trenches. By day I do ASP .NET development, but by night, I do contract work as a C programmer in Linux writing drivers for a drive-through order confirmation system. Tonight I'll be in a live, running restaurant, writing a driver for a system I've never seen. :) Who said there's no excitement being a geek?
Well, work is calling... Best wishes to all.
Apparently, Dell uses an ASP .NET application written in C# for at least part of their site. I'm in the process of ordering a new laptop--nothing fancy, just something to do some light-weight at-home development, and play Baldur's Gate on. I called Dell to order a dock station for my new laptop, spent some with the customer service rep (she was very helpful, but the language barrier made it a lot harder to find what I needed than I really think it had to be), and then tried to check on my account status using the web site. Well, the site wouldn't let me log in, and exposed the error to me, along with a very helpful stack trace.
So, I wrote what I hope will be a helpful email to the webmaster explaining how the error occurred, copied him on the stack trace, and explained how to prevent the end-user (myself) from ever seeing an unhandled error. In my own ASP .NET applications, I almost always create a routine in Application_OnError to send myself an email with any unhandled exceptoins. I also create a custom errors page which I'll redirect the user to, apologizing for the error, explaining that I've been notified of it, and that we're going to get it fixed as soon as possible. What other unhandled error strategies do you use? As an aside, I found it kind of fun to be “in the know“ on what was happening. Probably the programming advice I gave was going to be implemented anyway--or some variant thereof. Still, I got my geeky kicks out of it.
The overall customer service experience was good. I'm ordering an inspiron, but I really like the latitude docking station and monitor stand. The latitude docking station is incompatible with the inpiron, and I couldn't find a similar bundle for the inspiron (hint, hint, to those Dell guys.) After we broke through the language barrier, the customer service rep was a champ. She really went the extra mile. She went to her supervisor and got them to break a monitor stand out of the latitude bundle and send it to me with the docking station I had picked out for the inspiron.
That attitude in customer service really has a huge impact. Even though my initial experience was frustrating, and even though their site broke, my general feeling about this experience with them is very positive.
Dude, I'm getting a Dell! (Okay, that last was extremely cheesy, but what can I say?)
This is the transcription of the ACTUAL radio conversation between the British and the Irish off the coast of Kerry, October 1998. Radio conversation released by the Chief of Naval Operations 10-10-98.
IRISH: Please divert your course 15 degrees to the south to avoid a collision.
BRITISH: Recommend you divert your course 15 degrees to the north to avoid a collision.
IRISH: Negative. You will have to divert your course 15 degrees to the south to avoid a collision.
BRITISH: This is the Captain of a British Navy Ship. I say again, divert YOUR course.
IRISH: Negative. I say again, you will have to divert YOUR course.
BRITISH: THIS IS THE AIRCRAFT CARRIER HMS BRITIANNIA! THE SECOND LARGEST SHIP IN THE BRITISH ATLANTIC FLEET. WE ARE ACCOMPANIED BY THREE DESTROYERS, THREE CRUISERS AND NUMEROUS SUPPORT VESSELS. I DEMAND YOU CHANGE YOUR COURSE 15 DEGREES NORTH. I SAY AGAIN, THAT IS 15 DEGREES NORTH OR COUNTER-MEASURES WILL BE UNDERTAKEN TO ENSURE THE SAFETY OF THIS SHIP.
IRISH: We are a lighthouse................Your Call.