How to call a web user control through C#?
-
Hi every one! my application is in ASP.NET/C# 2005. I want to call a web user control from C# code and display it on a specific location on page. is it possible? also is it possible to set values in controls of user control from the page where it is called? Actually i want to display a table having different controls, X number of times depending on count of files in a folder and also set their values dynamically. should i use user control for this? if yes then how? and if no then what else could be used? Regards, Affan Ahmad Toor
.................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
-
Hi every one! my application is in ASP.NET/C# 2005. I want to call a web user control from C# code and display it on a specific location on page. is it possible? also is it possible to set values in controls of user control from the page where it is called? Actually i want to display a table having different controls, X number of times depending on count of files in a folder and also set their values dynamically. should i use user control for this? if yes then how? and if no then what else could be used? Regards, Affan Ahmad Toor
.................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
Of course. Your user control is a member variable of the code behind class - do what you want with it. You'd have to use CSS to position it precisely on the page.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Of course. Your user control is a member variable of the code behind class - do what you want with it. You'd have to use CSS to position it precisely on the page.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Thanks for reply... My user control contains link buttons and labels, i want to pass the text and URL to link buttons/labels dynamically. is it possible? and how? i googled but could not find any help. Thanks in advance... Regards, Affan Ahmad Toor
.................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
-
Thanks for reply... My user control contains link buttons and labels, i want to pass the text and URL to link buttons/labels dynamically. is it possible? and how? i googled but could not find any help. Thanks in advance... Regards, Affan Ahmad Toor
.................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
I recommend you buy a basic book on object oriented programming in whatever language you're using, and read it. As I said, your control is a member of your class, you can access it's methods and properties from there. Don't make your controls public tho, just expose the properties you want to set, such as the text.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
I recommend you buy a basic book on object oriented programming in whatever language you're using, and read it. As I said, your control is a member of your class, you can access it's methods and properties from there. Don't make your controls public tho, just expose the properties you want to set, such as the text.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Thanks for reply, i got your point, this part of problem is solved. but one problem is stil there...how can i call user control using C# code? as i mentioned earlier that i want to decide at runtime that how many time user control must be displayed, so how can i do it? only method i know is to add it in page using HTML code like: "" can i do it on page load within a loop, using C# code? Regards, Affan Ahmad Toor .................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!