473,543 Members | 1,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 46387
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 NameOfControlOn Page As MyControl
protected MyControl NameOfControlOn Page;

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:

NameOfControlOn Page.PropertyOn e = "";

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***@regonlin e.com> wrote in message
news:32******** *************** ***@posting.goo gle.com...
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***@regonlin e.com> wrote in message
news:32******** *************** ***@posting.goo gle.com...
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
1545
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 "codebehind" page. Function declaration: Sub MyFunction(ByVal sender As Object, ByVal e As System.EventArgs)
0
2235
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 successfully gotten it working. The only problem I have is with passing parameters to the Windows Forms User control from IE I am using the Object tag...
1
1422
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 the supplied parameters parameter1 and parameter2 Now my question : I've found two ways to add controls dynamically to my page :
1
13641
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 and set methods on the user control "editButton.ascx" which work fine. How do i pass parameter into the user controls "c1", "c2" ? Here is a bit...
4
7151
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" OR... the only way to do it is to use the QueryString or Session object?
5
1318
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 from the content control, without refreshing the default page. Currently, to change the content I refresh the default page by doing a...
4
1114
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
979
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 checking if there was some object found while searching (this control is used for searching). If so, I am calling my event CustomerSelected passing ID of...
6
11059
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 how those properties are set. I want to be able to do two other things: a) add User control instances to my page, filling in the place of...
0
7354
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7693
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4898
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3394
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3394
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1824
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.