Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 14th, 2003, 04:19 AM
Registered User
 
Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamically loaded user conrol

Hi Friends,

Iam Dynamically loading user controls in my login page like this....

Control loginControl=LoadControl("owrFooterLogin.ascx");
            loginPanel.Controls.Add(loginControl);
            ((owrFooterLogin)loginControl).MyEvent += new owrFooterLogin.myEventHandler(this.fireEventHandle r);

My user control has only one button,To handle events i used delegates ,
 at the run time i try to change the text of the button by adding property in user control like this..
public string btnText
        {
            set
            {
                login.Value=value;
            }
        }

when i try to set the value from main page its giving error saying object not set...

i have tried to set the value like this

owrFooterLogin login=new owrFooterLogin();
                loginFooter.btnText= "Sorry try again!";

How we can set the property for dynamically loaded user controls..

plz help me in this regard
thanks
vishnu
 
Old October 14th, 2003, 08:47 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I don't use C# so my syntax may be a bit incorrect...

owrFooterLogin loginControl = (owrFooterLogin)LoadControl("owrFooterLogin.ascx") ;
loginControl.btnText= "Sorry try again!";
loginPanel.Controls.Add(loginControl);
loginControl.MyEvent += new owrFooterLogin.myEventHandler(this.fireEventHandle r);

You always need to use "LoadControl" when dynamically loading user controls. Then, once they are converted into the right class you can do whatever you need including setting values on properties you've created.

Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating User DSN dynamically jai2k Beginning VB 6 0 November 23rd, 2004 06:00 AM
Loading user control dynamically from code-behind jacob ASP.NET 1.0 and 1.1 Basics 2 April 12th, 2004 06:06 PM
Directly referencing a conrol based on a string Bugsy VS.NET 2002/2003 6 April 11th, 2004 07:38 PM
Programmatically Loaded User Control Event Handlin cgoldrin ASP.NET 1.0 and 1.1 Professional 4 December 2nd, 2003 09:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.