Wrox Programmer Forums
|
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 June 7th, 2005, 01:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default Pass Parameter to Control

I have a control that I load dynamically on a page within a Placeholder based on a users previous selection. It works fine, but I need to pass the control a parameter and don't know how to do this since its created on the fly...

e.g.,

Placeholder1.Controls.Add(LoadControl("mycontrol.a scx")) works fine but I need to do something like:

Placeholder1.Controls.Add(LoadControl("mycontrol.a scx?myval=valuehere"))

I get error saying the control must have an .ascx extension...


I also tried this using one of the controls properties:

Dim c As Control
c = ParseControl("<uc1:mycontrol id='Mycontrol1' runat='server' myval='" & strValue & "'></uc1:mycontrol>")
Placeholder1.Controls.Add(c)

and this gives me the error:
Parser Error. Unknown server tag 'uc1:mycontrol'.

???

-------------------------
Beware of programmers with screwdrivers...
__________________
-------------------------
Beware of programmers with screwdrivers...
 
Old June 8th, 2005, 04:17 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 186
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

The User control doesnt cant have a diifernt Query string. you can access the same of the page.

You can also pass paramater by creating properites for the user control and then use find control to set the params

Prashant

 
Old June 8th, 2005, 02:13 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Along of the lines of what Prashant is saying...

Create a public property on your control:

   Public Property myval
      ...
   End Property

Then you load your control similar to how you have done but to a declared variable of the control class type:

   Dim ctlMyControl As MyControl
   ctlMyControl = CType(LoadControl("mycontrol.ascx"), MyControl)

Then you can set your property:

   ctlMyControl.myval = "valuehere"

Then add the control to the placeholder:

   Placeholder1.Controls.Add(ctlMyControl)

-Peter
 
Old June 8th, 2005, 02:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default

Thanks to both of you I'll give that a try!

:D

-------------------------
Beware of programmers with screwdrivers...





Similar Threads
Thread Thread Starter Forum Replies Last Post
pass parameter naeem_ul_hussan Classic ASP Basics 2 August 30th, 2007 11:18 AM
Pass a parameter in a link jmss66 Classic ASP Basics 1 October 20th, 2006 02:23 PM
How to pass parameter to sub-report . azeerum Access 1 January 3rd, 2005 04:26 PM





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