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   

My Links

Ads Via DevMavens

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<March 2010>
SMTWTFS
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Comment Stats

DayTotal% of Total
Sunday 2056.8%
Monday 42514.1%
Tuesday 51917.2%
Wednesday 55518.4%
Thursday 58019.2%
Friday 54718.1%
Saturday 1886.2%
Total 3019100.0%

Hour1Total% of Total
12:00 AM 782.6%
1:00 AM 812.7%
2:00 AM 682.3%
3:00 AM 822.7%
4:00 AM 692.3%
5:00 AM 1264.2%
6:00 AM 1183.9%
7:00 AM 1816.0%
8:00 AM 1926.4%
9:00 AM 1585.2%
10:00 AM 1886.2%
11:00 AM 1936.4%
12:00 PM 2016.7%
1:00 PM 1846.1%
2:00 PM 1695.6%
3:00 PM 1354.5%
4:00 PM 1153.8%
5:00 PM 1073.5%
6:00 PM 1013.3%
7:00 PM 1073.5%
8:00 PM 923.0%
9:00 PM 882.9%
10:00 PM 913.0%
11:00 PM 953.1%
Total 3019100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 4.97159
Monday 4.80384
Tuesday 4.04477
Wednesday 7.39680
Thursday 6.26676
Friday 5.07466
Saturday 4.78177
Total 5.403019

Hour1 Entry MadeAvg.Total
12:00 AM 5.2937
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 3.8550
8:00 AM 3.72134
9:00 AM 6.06297
10:00 AM 5.63276
11:00 AM 4.22194
12:00 PM 6.16351
1:00 PM 3.09133
2:00 PM 4.89230
3:00 PM 7.64321
4:00 PM 4.00108
5:00 PM 6.07170
6:00 PM 4.64116
7:00 PM 8.95188
8:00 PM 8.63164
9:00 PM 5.00115
10:00 PM 6.31101
11:00 PM 4.5732
Total 5.403019

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


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles