 |
|
 |
Hi I notice that when you move a User control from 2003 to 2005 well it keep some code which is not needed in the code behind:
private void InitializeComponent()
{
this.Load += new EventHandler(this.Page_Load);
}
just remove :
this.Load += new EventHandler(this.Page_Load);
that help me from run twice Page_Load method
Hope that help
Lets make better software.
Alexander at MGCA Ltd
|
|
|
|
 |
|
 |
I think this is not dynamic or at least not what I was looking for (the artical header is misleadding), cause you know in advance the control that this page it will referance, so if you need 10 user-controls to be added according to user seletction, you will have to add 10 refernace in the page, Right ??
Thanks, Best Regards
Waleed Seada
|
|
|
|
 |
|
 |
You're right Waleed. The title is very misleading.
|
|
|
|
 |
|
 |
No youre not.
This is the way to dynamic add a usercontrol to a webpage.
You could this code past it bewteen a for loop and you have youre dynamicely add webcontrol on youre site
|
|
|
|
 |
|
 |
How to put this in a loop? Could you show me the sample code?
|
|
|
|
 |
|
 |
This is really misleading. i think the writer should stop acting smart and remove this post.
|
|
|
|
 |
|
 |
how can i load a conrtol a run-time without i have to reference the control?
|
|
|
|
 |
|
|
 |
|
 |
This example is probably one of the most simplistic articles I've seen in a long time. It seems like this author reads a very simple article and spits it back out to say he published another article.
Ever thought of posting an original article that isn't in a Quick Start guide or newbie tutorial page and then claiming it as your own?
|
|
|
|
 |
|
 |
I agree, what a waste of space...
|
|
|
|
 |
|
 |
Jeez man...It is actually a simple tutorial for a newbie... Helpful I think for people that are not used to UI. It's sad that people feel they should rip on someone elses correctly implemented work (however simple). Things would be different if he was wrong.
Play Nice
|
|
|
|
 |
|
 |
Well if its for newbies he could have explained things a little more - placeholders for instance. I think you need to put in a little more work than this before it can be called an article.
|
|
|
|
 |
|
 |
Sure, this article is simple, but it helps. I am new to asp.net, and I didn't know how to dynamically instantiate a user control. I didn't know that a PlaceHolder needed to be used. Sure, mabye I could have used MSDN library or the quickstarts, but searching the MSDN Library inside Visual Studio to find what I wanted to know was a difficult task. (You must admit that the 'search' feature in Vis Studio, with MSDN Library installed, is primitive compared to Google.) What I am saying is this: sometimes it's much easier to search the web to find out what I need to know than it is to search the msdn library, and lucky for me this article was here to answer my newbie question.
It answered my question, but yes, it could have been more developed and talked about PlaceHolders a bit more. But since I now know PlaceHolders are needed, I can lookup PlaceHolders in the MSDN Library or something.
|
|
|
|
 |
|
 |
Yes, maybe he should play nice, but then again the article is full of errors. Perhaps before making a simple tutorial, one should see if it's accurate.
First off, the "Reference Control" direct can go, if you are going to dynamically load a control then you don't need this, it goes against the philosophy of a dynamic load.
The rest can stay, it's relatively accurate, however it would be helpful to specify that it should be invoked in the Page_Init event and not in the Page_Load, as the Page_Load will play around with the viewstate and make the control forget it's current state.
I have the greatest respect for people that make the effort, but this gentleman should have worked on the article a bit more and do his research before posting it up.
Karell
MCP, MCSE
|
|
|
|
 |
|
 |
First off let me say that this article is not "full of errors". It is absolutely correct from a syntactical standpoint. Can you show me how he is wrong from a syntactical standpoint? The author makes no representations that his "Sample", as it is adequately categorized here on Code Project, conforms to "Best Practices", or any other UI methodology. This is obviously not a best practices approach to User Controls or the loading thereof. The bottom line is that you are misleading many other newbies who read the first sentence of your post. I think that is ethically wrong.
I do agree with you about the philosophy of what is needed (or not needed) to dynamically load a control, though I think that if you really wanted to contribute to this site then perhaps you would offer an explanation as to why the user should not (and doesn't have to) add a page directive for the control reference.
As for your third sentence...there are many ways to manage ViewState for items on a page, or a page itself. Remember, the author did mention a couple of methods of loading the control(s) which you are simply reiterating.
The fact is that the gentleman that authored this sample could have put some more effort into this sample, but after all...it is just a sample. If you truly had respect for people that make the effort, then you would help those people learn by providing some constructive criticism as I am doing for you in this post.
You should always err on the side of being helpful, not critical. That is just part of being a more advanced developer.
All that to say; If anyone needs help figuring out how to dynamically load a user control I'd be happy to help out.
Jason
MCSD
-- modified at 21:05 Thursday 24th November, 2005
|
|
|
|
 |
|
 |
oooh, let me warm my hands on these flames!!!
I too am a nubie, This article helped me a little - google took me strait to it. I agree with Jason, in that its better to err on the side of being helpfull, rather than critical in your posts.
If you're going to flame someone, at least have the balls to put your name to it!
Glyn
|
|
|
|
 |
|
 |
This really helped me. I had to change the Load to Page_Init rather than to Page_load. It works now. Thanks man.
grg
|
|
|
|
 |