Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > More passing parameters to dynamically loaded user controls

Reply
Thread Tools

More passing parameters to dynamically loaded user controls

 
 
voro.cibus@gmail.com
Guest
Posts: n/a
 
      07-26-2005
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 asplaceholder 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.

 
Reply With Quote
 
 
 
 
TE
Guest
Posts: n/a
 
      07-26-2005
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


<(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed) 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 asplaceholder 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.
>



 
Reply With Quote
 
 
 
 
JB McMichael
Guest
Posts: n/a
 
      07-26-2005
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
>
>
> <(E-Mail Removed)> schrieb im Newsbeitrag
> news:(E-Mail Removed) 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 asplaceholder 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.
>>

>
>
>

 
Reply With Quote
 
TE
Guest
Posts: n/a
 
      07-26-2005
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" <(E-Mail Removed)> schrieb im Newsbeitrag
news:dc6fjq$8a9$(E-Mail Removed)...
> 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
>>
>>
>> <(E-Mail Removed)> schrieb im Newsbeitrag
>> news:(E-Mail Removed) 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 asplaceholder 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.
>>>

>>
>>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically Loaded controls loading other controls =?Utf-8?B?V291dGVy?= ASP .Net 3 02-27-2006 07:25 PM
More passing parameters to dynamically loaded user controls JB McMichael ASP .Net 0 07-26-2005 10:21 PM
Passing Parameters to User Controls that are Dynamically Loaded in Placeholders Josh ASP .Net Building Controls 1 05-26-2004 06:41 AM
Passing Parameters to User Controls that are Dynamically Loaded in Placeholders Josh ASP .Net Web Controls 1 05-26-2004 06:41 AM
Passing Parameters to User Controls that are Dynamically Loaded in Placeholders Josh ASP .Net 1 05-26-2004 12:42 AM



Advertisments