473,414 Members | 1,684 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,414 software developers and data experts.

Passing parameters to user controls

Hello.
I'm having problem with passing parameters from .aspx file to user
control.
Could anyone tell me how to pass parameters from .aspx file to user
control(.ascx) and how to recieve parameters at .ascx?
Thank you for your help!
Nov 17 '05 #1
2 46378
Open the CodeBehind file and add the user control to the controls
collection. Not sure why, but, by default, a user control is placed on the
page but never given a corresponding line in the CodeBehind file.

Dim NameOfControlOnPage As MyControl
protected MyControl NameOfControlOnPage;

You can see the lines of other controls in your CodeBehind, so the above
templates are suspect. Once you do this, you will be able to use:

NameOfControlOnPage.PropertyOne = "";

to set values.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

************************************************** **************************
****
Think Outside the Box!
************************************************** **************************
****
"Akira" <ak***@regonline.com> wrote in message
news:32**************************@posting.google.c om...
Hello.
I'm having problem with passing parameters from .aspx file to user
control.
Could anyone tell me how to pass parameters from .aspx file to user
control(.ascx) and how to recieve parameters at .ascx?
Thank you for your help!

Nov 17 '05 #2
use properties...or public fields :)

user control:

private _ValueID as integer
Public Property ValueID as integer
Get
return _ValueID
ENd Get
Set (byval value as integer)
_ValueID = value
end set
end property

From within the user control you can simply refer to "ValueID" from
thereonin to get the value that was assigned to it by the parent.
Parent:
Two methods
<control:name runat="server" id="cntrl" ValueID=3 />

in codebehind
cntrl.ValueID = 3
Karl

"Akira" <ak***@regonline.com> wrote in message
news:32**************************@posting.google.c om...
Hello.
I'm having problem with passing parameters from .aspx file to user
control.
Could anyone tell me how to pass parameters from .aspx file to user
control(.ascx) and how to recieve parameters at .ascx?
Thank you for your help!

Nov 17 '05 #3

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

Similar topics

0
by: Paul Allan | last post by:
I am new to ASP.net (intermediate ASP developer). I am developing a ASP.net web application and I am having some difficulty calling and passing parameters to a function that is declared in my...
0
by: Neelima Godugu | last post by:
Hi All, I have developed a windows forms user control, which I am going to host in Internet Explorer.. I am familiar with the security settings requirement inorder to do the above. I have...
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...
4
by: David Freeman | last post by:
Hi There! I'm just wondering if there's a way to pass parameters (as if you were passing parameters to a ASCX web control) when calling an ASPX page? e.g. MyDetailsPage.UserName = "david" ...
5
by: Dranreb | last post by:
Hello, I use a template whereby my default page contains various user controls - i.e. "Header", "Footer", "Navigation", "Content". On some occaisions I'd like to manipulate the other controls...
4
by: David Gilbert | last post by:
Is better to pass the same SQL connection to all of my user controls. Should I make a global object for my SQL connection, or is there some other better choice out there. Thanks DG
0
by: Piotrek | last post by:
Hi. I am developing a web app. On the main page I have two user controls: searchControl and detailsControl. In the searchControl I have a GridView. On this GridView DataBound handler I am...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.