Scott on Writing

Musings on technical writing...

My Latest MSDN Article in Now Online

It's been a few months since my last MSDN Online article appeared in the ASP.NET DevCenter, but I'm happy to announce that the dry spell has ended with the publication of.my latest article, Creating Dynamic Data Entry User Interfaces.  This article's primary focus is to serve as the source for information on using dynamically added Web controls in an ASP.NET page, a common question thread in the newsgroups and online forums.  (So, admittedly, the title is a bit misleading...)

To illustrate the lessons learned the last third of the article or so examines an application that allows custom data entry user interfaces to be created based on some criteria.  It allows for an administrator-type user to specify what questions a particular type of user needs to answer.  Then, on the data entry page, the data entry forms are dynamically loaded based on the user visiting.

My next MSDN Online article will be on skmFAQs.NET, a packaged application for putting FAQs online.  (I'm still looking for users who are interested in giving skmFAQs.NET a whirl and providing usability feedback and suggestions!!)

posted on Friday, January 21, 2005 9:43 AM

Feedback

# re: My Latest MSDN Article in Now Online 1/23/2005 1:04 AM Mohamad Taheri

Very usefull. thanks to publishing :)

# re: My Latest MSDN Article in Now Online 1/23/2005 10:11 PM Pravin

Hi I am not sure this is the place to ask my question but i didn't where to.

Article is excellent but I have one issue.

I am unable to understand that if the Backcolor property can be stored in view state (we are assigning that in 'Not Page.IsPostBack') then why not the control be stored in the Page view state. Isn't this bit illogical? I mean create the control everytime but set the property once.

And also on page reload, when we create the control - does ASP engine check that this control already exists in view state? And then it assigns its old properties. When I create a control it means creating a brand-new control -with default properties - I suppose this is the normal behavior expected. (like WinForms controls). Thnx.

# re: My Latest MSDN Article in Now Online 1/24/2005 9:54 AM Scott Mitchell

Pravin, the BackColor property is only stored in ViewState if the property is set AFTER the Track ViewState Flag is set to True, which happens AFTER the Initialization stage.

ViewState doesn't store controls, it stores a control's *state* that has been programmatically altered from the control's default state. You might want to check out this article of mine for further info on ViewState:

Understanding ASP.NET View State
http://tinyurl.com/5awdk

# re: My Latest MSDN Article in Now Online 1/26/2005 6:40 AM Chris F

Good timing on this article, but I've run into a problem.

I'm trying to dynamically add UserControls to a placeholder, and it seems that the user control is never getting initialilzed.

Do the same rules not apply to user controls?

Is there any way to dynamically add user controls to a page?

# re: My Latest MSDN Article in Now Online 1/26/2005 7:16 AM Scott Mitchell

Chris, when you add a User Control to the page, it goes through all stages to "catch up" to the page's stage (including Initialization). I trust you are loading the User Control using Page.LoadControl() rather than instantiating a new instance of the UC?

# re: My Latest MSDN Article in Now Online 1/26/2005 8:21 AM Pravin

Yes Viewstate doesn't store controls, but what I am saying is if viewstate can remember the Backcolor property why can't it help asp.net remember to instantiate a control again which had been instantiated previously by code.

What I mean is, as ASP.NET is making Windows and Web programming come closer, this requirement to instantiate controls everytime on all postbacks - is unlike Windows programming. And I believe ASP.NET has enough stuff in it to make this possible quite easily.

Point is, once I create a control in code it should remain there, I needn't worry about creating it again on next postback. If I create one again with the same id - it should give some kind of error.

This will really make it a lot closer to the windows way of programming.

# re: My Latest MSDN Article in Now Online 1/26/2005 12:19 PM Chris F

Scott - That was the problem. Changing to LoadControl fixed that part of it...

Next problem that drop down lists aren't getting set properly.

In Page_Load, I add 3 user controls to a placeholder.

In Page_PreRender, I get the placeholder, then do a FindControl() for each uc. I then assign data to properties in each UC, call uc.DataBind() which should set the DDL.selectedValue (and stepping thru it with the debugger, I can see that it does change it).

However, the resulting page doesn't have the proper item selected.

I do have the ddl init in an "if not isPostback" inside the UC. This one has me about ready to start pulling my hair out :)


# re: My Latest MSDN Article in Now Online 1/26/2005 5:57 PM Scott Mitchell

Pravin, your ideas aren't feasible for the Internet, since there may be an indeterminent time between when the user makes his or her first request and when he or she makes a postback. So how long do you "remember" the control's existence on the server side while waiting for a postback that might never come? And if you put some time limit on it, what of the users who come back *after* that timelimit has expired?

Or do you think there would be some way to maintain control information across postbacks without hogging Web server resources? The only way I can fathom is by serializing the control state to disk, since Web server's could affordably have gigs of hard drive space. However, performance would likely be a concern here since disk access is so much more expensive than memory access; granted, most of these concerns could be surmounted with intelligent caching of files at the OS level... But the point is, I don't think you're going to remove this fundamental property of the Internet; technologies like ASP.NET just help blur those lines/limits.

# My Latest MSDN Article in Now Online 1/28/2005 2:13 PM Vishal

Great Article Scott ! ...

# re: My Latest MSDN Article in Now Online 2/22/2005 4:43 PM Faisal

Scott, just want to bring to your attention, unless you know already, that there are a few missing image files of figures on the the article's page on MSDN.

http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnaspp/html/DynamicUI.asp

Didn't spoil my enjoyment of it too much though, so high was my regard of its content.

Great article. Keep up the good work.

# re: My Latest MSDN Article in Now Online 2/22/2005 4:49 PM Scott Mitchell

Thanks for the heads up, Faisal. I've alerted by editor on MSDN and he's on the case now, so it ought to be fixed sooner than later.

Thanks again.

# re: My Latest MSDN Article in Now Online 2/24/2005 10:35 AM Satish

Thanks for the good article. Was useful for my application. But I ran into one problem
i Have a page that displays details of a record and also displays buttons used to take an action on the record. I create these buttons dynamically based on the mode of the page.
In Add Mode - Buttons are Save,
In Display Mode - Buttons are, Change, Delete, New
In Modify Mode - Buttons are Save, New

When a user clicks Save, I should save the record in db, change mode to display, display the record and show the buttons accordingly. Since the save event is fired after the page_load event. I have to create the buttons in the Page_Prerender event. The page is succesfully built. But when i click on a button in this page, the event does not fire. I did some google search and found similar problems but no reasons or solutions. Any help is appreciated

# re: My Latest MSDN Article in Now Online 7/2/2005 2:50 AM Jim

Satish:

I had the same problem when I was checking for a !PostBack to dynamically load my user controls. Once I took this out and loaded into the place holder on every load my problem was solved.

Not the best but it's late and I have hours more of work. :)

# re: My Latest MSDN Article in Now Online 9/30/2005 12:12 AM Az

Awesome ... I was just thinking of making such a control as i would really need one in forth comming project and its there in ur blog!!! ... tell u what whatever minor problem there would be in this control ... the work is just briliant :)

Title:  
Name:  
Url:
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments   

Add To Your Reader

My Links

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<May 2008>
SMTWTFS
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

Comment Stats

DayTotal% of Total
Sunday 1866.8%
Monday 37913.9%
Tuesday 45316.7%
Wednesday 50418.5%
Thursday 53519.7%
Friday 49418.2%
Saturday 1666.1%
Total 2717100.0%

Hour1Total% of Total
12:00 AM 652.4%
1:00 AM 682.5%
2:00 AM 622.3%
3:00 AM 742.7%
4:00 AM 572.1%
5:00 AM 1033.8%
6:00 AM 1084.0%
7:00 AM 1585.8%
8:00 AM 1716.3%
9:00 AM 1475.4%
10:00 AM 1716.3%
11:00 AM 1816.7%
12:00 PM 1886.9%
1:00 PM 1696.2%
2:00 PM 1605.9%
3:00 PM 1324.9%
4:00 PM 1073.9%
5:00 PM 923.4%
6:00 PM 913.3%
7:00 PM 963.5%
8:00 PM 833.1%
9:00 PM 782.9%
10:00 PM 792.9%
11:00 PM 772.8%
Total 2717100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.54144
Monday 5.22339
Tuesday 4.28419
Wednesday 7.67637
Thursday 6.90607
Friday 5.48411
Saturday 5.33160
Total 5.842717

Hour1 Entry MadeAvg.Total
12:00 AM 5.0035
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 7.0035
8:00 AM 5.35107
9:00 AM 6.32278
10:00 AM 6.47246
11:00 AM 4.41181
12:00 PM 6.88330
1:00 PM 3.00111
2:00 PM 5.41222
3:00 PM 8.64285
4:00 PM 4.0589
5:00 PM 5.92154
6:00 PM 4.52113
7:00 PM 9.67174
8:00 PM 9.80147
9:00 PM 5.05111
10:00 PM 5.4265
11:00 PM 4.5732
Total 5.842717

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles