473,408 Members | 2,888 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,408 software developers and data experts.

Pass parameters to User Control

Ben
Hi

I am using a User Control which is referenced by an ASPX page.

How can I pass a string parameter to the user control, from the base ASPX
page.

Thanks

Ben
Nov 18 '05 #1
5 3923
Hi Ben,

Create a public method in the usercontrol and access the same from the aspx
page.

Ex:

Code in myusercontrol.ascx.cs
public void PublicMethodInUsercontrol(string valuetopasstocontrol)
{
privatevariable = valuetopasstocontrol;
}

Code in the aspx page.

usercontrolinstance.PublicMethodInUsercontrol("MyV alueFromPage");

HTH
Regards
Ashish M Bhonkiya

"Ben" <Be*@nospam.com> wrote in message
news:u4**************@TK2MSFTNGP12.phx.gbl...
Hi

I am using a User Control which is referenced by an ASPX page.

How can I pass a string parameter to the user control, from the base ASPX
page.

Thanks

Ben

Nov 18 '05 #2
For this purpose I used to create properties (in user control). This way you
can also pass parameters from aspx file (html).
You can access Session to retrieve values. There're plenty of ways. In case
you need some code, I'll try to post.

--
With the best wishes,
Shaul Feldman
"Ben" <Be*@nospam.com> wrote in message
news:u4**************@TK2MSFTNGP12.phx.gbl...
Hi

I am using a User Control which is referenced by an ASPX page.

How can I pass a string parameter to the user control, from the base ASPX
page.

Thanks

Ben

Nov 18 '05 #3
Ben
Sorry for the delay in replying:

I have heard that you can use this method to pass the parameter:

<%@Register tagprefix="CodeLib" Tagname="usrMain" src="usrMain.ascx" %>

<CodeLib:usrMain bodyData="usrText.ascx" linksPage="NoLinks"
requireSecure="False" runat="server" ID="usrMain"/>

But the problem is that I cannot seem to extract the data on the ASCX page

Thanks Ben

"Shaul Feldman" <sf******@writeme.com> wrote in message
news:e$****************@tk2msftngp13.phx.gbl...
For this purpose I used to create properties (in user control). This way you can also pass parameters from aspx file (html).
You can access Session to retrieve values. There're plenty of ways. In case you need some code, I'll try to post.

--
With the best wishes,
Shaul Feldman
"Ben" <Be*@nospam.com> wrote in message
news:u4**************@TK2MSFTNGP12.phx.gbl...
Hi

I am using a User Control which is referenced by an ASPX page.

How can I pass a string parameter to the user control, from the base ASPX page.

Thanks

Ben


Nov 18 '05 #4
Help! I have an aspx that loads the ascx with parameters in a
placeholder as textboxes. On my postback I can't get the values out
of the textboxes. They are still on the screen so I'm sure they are
there.

I'm having a hard time. I've been told they should just be there.
aspx
ascx
ascxwp

The ascxwp is the user control that holds the textboxes.

I assume someone has figured this out. We have 3 asp programmers and
we are all stumped.

"Shaul Feldman" <sf******@writeme.com> wrote in message news:<e$**************@tk2msftngp13.phx.gbl>...
For this purpose I used to create properties (in user control). This way you
can also pass parameters from aspx file (html).
You can access Session to retrieve values. There're plenty of ways. In case
you need some code, I'll try to post.

--
With the best wishes,
Shaul Feldman
"Ben" <Be*@nospam.com> wrote in message
news:u4**************@TK2MSFTNGP12.phx.gbl...
Hi

I am using a User Control which is referenced by an ASPX page.

How can I pass a string parameter to the user control, from the base ASPX
page.

Thanks

Ben

Nov 18 '05 #5
Implement Properties inside of your UserControl
e.g.

Public Property FirstName() as String
Get
Return txtFirstName.text
End Get
Set (value as String)
txtFirstName.text=value
end set
end property

Then just access the properties
"Lynne K." <lt****@assurity.com> wrote in message
news:7a**************************@posting.google.c om...
Help! I have an aspx that loads the ascx with parameters in a
placeholder as textboxes. On my postback I can't get the values out
of the textboxes. They are still on the screen so I'm sure they are
there.

I'm having a hard time. I've been told they should just be there.
aspx
ascx
ascxwp

The ascxwp is the user control that holds the textboxes.

I assume someone has figured this out. We have 3 asp programmers and
we are all stumped.

"Shaul Feldman" <sf******@writeme.com> wrote in message

news:<e$**************@tk2msftngp13.phx.gbl>...
For this purpose I used to create properties (in user control). This way you can also pass parameters from aspx file (html).
You can access Session to retrieve values. There're plenty of ways. In case you need some code, I'll try to post.

--
With the best wishes,
Shaul Feldman
"Ben" <Be*@nospam.com> wrote in message
news:u4**************@TK2MSFTNGP12.phx.gbl...
Hi

I am using a User Control which is referenced by an ASPX page.

How can I pass a string parameter to the user control, from the base ASPX page.

Thanks

Ben

Nov 18 '05 #6

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

Similar topics

0
by: Jill Graham | last post by:
Hi folks, I'm calling some custom made user controls from within my .aspx web page using newControl = Page.LoadControl("myControl.ascx") Page.Controls.Add(newControl) My control has two...
2
by: Jeff Thur | last post by:
I am running a SQL Stored Procedure that will give the user a count of how many records are in the database as per certain criteria. I'm using the Execute Scalar Method. I have no problem passing...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
0
by: Daimy | last post by:
I meet the same problem below, please help me! Thanks! //written by some one I have developed a windows forms user control, which I am going to host in Internet Explorer.. I am familiar...
2
by: Ben | last post by:
Hi I am using a User Control which is referenced by an ASPX page. How can I pass a string parameter to the user control, from the base ASPX page. Thanks Ben
2
by: craigkenisston | last post by:
Hi, I have a web user control that displays "items" by user, by category, newest "items", etc. It works very well and does what I want, this is done with parameters in the page that holds the...
3
by: Wang Xiaoning | last post by:
I have an customerdetail.xsl sheet ---------------------------------------------------------- <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0"...
9
by: keith | last post by:
I use this code to load a user control at runtime: Control c = Page.LoadControl(Request.ApplicationPath + "/User_Controls/website_design.ascx"); UserControlPlaceHolder.Controls.Add(c); ...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
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...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.