473,324 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

More passing parameters to dynamically loaded user controls

I have been reading up on this all day, and I can't find the answer (or
more likely, don't understand the answers I have found) to my problem.

I have a table that stores the name of my ascx page. My main page can
be called on to load any of the pages referenced in my table.
Therefore, I have no @Register controls in my aspx file.

What I do have is this
dim myUC as control = Page.LoadControl("~/reqforms/" &
GetReqForm(requestID))
mainForm.Controls.Add(myUC)

mainForm is an asp:placeholder I have in the apsx page.

Each of my ascx pages has a public property called rid. What I need to
do is pass requestID to the ascx's rid.

I have seen this mentioned
myUC = ctype(myUC, myUserControl).rid = requestID

The problem I have seen with these though is that they have a page
directive in which they set the classname of the user control. Since I
have no page directives for my dynamically loaded controls, how do I
set the classname? Or am I going in the wrong direction here?

I am basically at a loss, and at the edge of my understanding of vb.net
(been doing this for only 3 months now), so a clear answer with code,
preferably in vb.net would be of immense help to me.

Nov 19 '05 #1
3 3295
Hi,

maybe I misunderstand your problem - you mentioned that all of your ascx`s
have this attribute "rid" - so why not just implement an interface with this
property (rid in your example)? Or assuming "rid" is an attribute in your
aspx and so readable from the ascx? what about session?

Regards,

Thomas
<vo********@gmail.com> schrieb im Newsbeitrag
news:11*********************@z14g2000cwz.googlegro ups.com...
I have been reading up on this all day, and I can't find the answer (or
more likely, don't understand the answers I have found) to my problem.

I have a table that stores the name of my ascx page. My main page can
be called on to load any of the pages referenced in my table.
Therefore, I have no @Register controls in my aspx file.

What I do have is this
dim myUC as control = Page.LoadControl("~/reqforms/" &
GetReqForm(requestID))
mainForm.Controls.Add(myUC)

mainForm is an asp:placeholder I have in the apsx page.

Each of my ascx pages has a public property called rid. What I need to
do is pass requestID to the ascx's rid.

I have seen this mentioned
myUC = ctype(myUC, myUserControl).rid = requestID

The problem I have seen with these though is that they have a page
directive in which they set the classname of the user control. Since I
have no page directives for my dynamically loaded controls, how do I
set the classname? Or am I going in the wrong direction here?

I am basically at a loss, and at the edge of my understanding of vb.net
(been doing this for only 3 months now), so a clear answer with code,
preferably in vb.net would be of immense help to me.

Nov 19 '05 #2
First off, thanks for the reply.

I did not implement an interface because I don't know what that is.

And I thought about using the session scope, but for some reason it
seemed weak to me. Passing in a parameter seemed better somehow.

But again, I am still new to all of this, so my decisions are mainly
based on what I read on the internet.

-JB

Thomas Egginger wrote:
Hi,

maybe I misunderstand your problem - you mentioned that all of your ascx`s
have this attribute "rid" - so why not just implement an interface with this
property (rid in your example)? Or assuming "rid" is an attribute in your
aspx and so readable from the ascx? what about session?

Regards,

Thomas
<vo********@gmail.com> schrieb im Newsbeitrag
news:11*********************@z14g2000cwz.googlegro ups.com...
I have been reading up on this all day, and I can't find the answer (or
more likely, don't understand the answers I have found) to my problem.

I have a table that stores the name of my ascx page. My main page can
be called on to load any of the pages referenced in my table.
Therefore, I have no @Register controls in my aspx file.

What I do have is this
dim myUC as control = Page.LoadControl("~/reqforms/" &
GetReqForm(requestID))
mainForm.Controls.Add(myUC)

mainForm is an asp:placeholder I have in the apsx page.

Each of my ascx pages has a public property called rid. What I need to
do is pass requestID to the ascx's rid.

I have seen this mentioned
myUC = ctype(myUC, myUserControl).rid = requestID

The problem I have seen with these though is that they have a page
directive in which they set the classname of the user control. Since I
have no page directives for my dynamically loaded controls, how do I
set the classname? Or am I going in the wrong direction here?

I am basically at a loss, and at the edge of my understanding of vb.net
(been doing this for only 3 months now), so a clear answer with code,
preferably in vb.net would be of immense help to me.


Nov 19 '05 #3
Hi -

these solutions are just point of view dependant....

if your ascx is only used in this web-project context you could access
objects stored in session (query or whatever) - in my opionion - or you
could implement a property/variable in the aspx, that is read by the ascx.

otherwise - if your master is the asxc and it could be useable from
different webs, then think about the interface solution - but do not forget
to throw an error if your variable is not provided...

concerning interfaces i`d suggest looking for "interfaces .net" in google -
but in short: interfaces are kind of contracts. every class that implements
this interface has to follow this contract (meaning: implementing the
methods with it`s parameters that is defined in the interface) - one
advantage (in your example) - you can instantiate every class implementing
this interface by its interface name!

hope this could help you!

"JB McMichael" <jb@kno-where.com> schrieb im Newsbeitrag
news:dc**********@daisy.noc.ucla.edu...
First off, thanks for the reply.

I did not implement an interface because I don't know what that is.

And I thought about using the session scope, but for some reason it seemed
weak to me. Passing in a parameter seemed better somehow.

But again, I am still new to all of this, so my decisions are mainly based
on what I read on the internet.

-JB

Thomas Egginger wrote:
Hi,

maybe I misunderstand your problem - you mentioned that all of your
ascx`s have this attribute "rid" - so why not just implement an interface
with this property (rid in your example)? Or assuming "rid" is an
attribute in your aspx and so readable from the ascx? what about session?

Regards,

Thomas
<vo********@gmail.com> schrieb im Newsbeitrag
news:11*********************@z14g2000cwz.googlegro ups.com...
I have been reading up on this all day, and I can't find the answer (or
more likely, don't understand the answers I have found) to my problem.

I have a table that stores the name of my ascx page. My main page can
be called on to load any of the pages referenced in my table.
Therefore, I have no @Register controls in my aspx file.

What I do have is this
dim myUC as control = Page.LoadControl("~/reqforms/" &
GetReqForm(requestID))
mainForm.Controls.Add(myUC)

mainForm is an asp:placeholder I have in the apsx page.

Each of my ascx pages has a public property called rid. What I need to
do is pass requestID to the ascx's rid.

I have seen this mentioned
myUC = ctype(myUC, myUserControl).rid = requestID

The problem I have seen with these though is that they have a page
directive in which they set the classname of the user control. Since I
have no page directives for my dynamically loaded controls, how do I
set the classname? Or am I going in the wrong direction here?

I am basically at a loss, and at the edge of my understanding of vb.net
(been doing this for only 3 months now), so a clear answer with code,
preferably in vb.net would be of immense help to me.



Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
7
by: Tim T | last post by:
Hi, I have the need to use dynamically loaded user controls in a webform page. I have the controls loading dynamically, and that part works fine. this is the code used in a webform to dynamically...
1
by: Jill Graham | last post by:
Hi, I can use following syntax to add user controls directly to my pages : <XYZ:myControl parameter1="value1" parameter2="value2" runat="server" /> The control "myControl" is executed using...
1
by: Josh | last post by:
Hi Guys, I have been having a big problem with trying to pass parameters into a user control when the user control is dynamically loaded into a placholder. I am developing in c#. I have get...
3
by: Guadala Harry | last post by:
I have this scenario: ASPX Page dynamically loads userControl1 - which in turn dynamically loads userControl2. UserControl2 contains a TextBox Web Server control. When a user clicks a button in...
4
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three...
0
by: Matt Howeson | last post by:
I have a problem with a usercontrol that is dynamically loaded, from a web control and is not restoring it's viewstate properly. Here's the scenario. Within our content management system, I have...
0
by: JB McMichael | last post by:
I have been reading up on this all day, and I can't find the answer (or more likely, don't understand the answers I have found) to my problem. I have a table that stores the name of my ascx page....
1
by: Christian Resma Helle | last post by:
Hey guys, I'm working on an AJAX Enabled ASP.NET Web application. I have a TreeView web control and an PlaceHolder web control. My PlaceHolder is inside an UpdatePanel and AsyncPostBacks are...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.