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

User Controls and ASPX.CS

JV
I have created a user control UCQuery.acx. It consists of
a number of drop down list boxes. I created this control
because the same drop down list boxes must appear on
several aspx pages for user selection of data for input
into a database query.

So I have the ascx and I add it to my wp.aspx:

<%@ Register TagPrefix="uc1" TagName="UCQuery"
Src="UCQuery.ascx" %>

and

<uc1:ucquery id="UCQuery1" runat="server"></uc1:ucquery>

Now in my wp.aspx.cs I want to reference UCQuery1 but I
get an error.

I need to call public methods in the ascx from my aspx.cs
in order to get the user selections from the control and
pass them on.

Am I out of line in thinking this can be done with a user
control?

Thanks in advance,

JV
Nov 15 '05 #1
2 1443
"JV" <an*******@discussions.microsoft.com> wrote in message
news:0c****************************@phx.gbl...
I have created a user control UCQuery.acx. It consists of
a number of drop down list boxes. I created this control
because the same drop down list boxes must appear on
several aspx pages for user selection of data for input
into a database query.
Good reason for a user control. I have seen an app where the designer had a
control for everything, even those that would never be repeated.
So I have the ascx and I add it to my wp.aspx:

<%@ Register TagPrefix="uc1" TagName="UCQuery"
Src="UCQuery.ascx" %>

and

<uc1:ucquery id="UCQuery1" runat="server"></uc1:ucquery>

Now in my wp.aspx.cs I want to reference UCQuery1 but I
get an error.


Add the following line to your CodeBehind:

protected UCQuery UCQuery1;

template = protected {Class Name} {Name of object in page};

Then you should be able to do:

UCQuery1.property1 = "";

Not sure why Microsoft does not have this happen automagically when a
control is dropped, as I routinely work with controls in CodeBehind.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
Nov 15 '05 #2
What the deuce is this:

template = protected {Class Name} {Name of object in
page};

-----Original Message-----
"JV" <an*******@discussions.microsoft.com> wrote in messagenews:0c****************************@phx.gbl...
I have created a user control UCQuery.acx. It consists of a number of drop down list boxes. I created this control because the same drop down list boxes must appear on
several aspx pages for user selection of data for input
into a database query.
Good reason for a user control. I have seen an app where

the designer had acontrol for everything, even those that would never be repeated.
So I have the ascx and I add it to my wp.aspx:

<%@ Register TagPrefix="uc1" TagName="UCQuery"
Src="UCQuery.ascx" %>

and

<uc1:ucquery id="UCQuery1" runat="server"></uc1:ucquery>
Now in my wp.aspx.cs I want to reference UCQuery1 but I
get an error.
Add the following line to your CodeBehind:

protected UCQuery UCQuery1;

template = protected {Class Name} {Name of object in

page};
Then you should be able to do:

UCQuery1.property1 = "";

Not sure why Microsoft does not have this happen automagically when acontrol is dropped, as I routinely work with controls in CodeBehind.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************* ******** *************Think Outside the Box!
************************************************* ******** *************

.

Nov 15 '05 #3

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

Similar topics

2
by: Peter Jackson | last post by:
I'm using v2 of the UIP App. Block. I've created all my .aspx pages, all of which contain .ascx user controls. The .ascx user controls provide the standard server controls (i.e., LinkButtons, etc.)...
1
by: Robert Howells | last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad architecture. I'd appreciate some feedback on the the wisdom (or lack thereof) in attempting the following: I'm not new...
1
by: Reza Nabi | last post by:
Bakground: I have a webform (LoadCtl.aspx) which loads the user control to a placeholder dynamically based on the ctlName querystring passed in the URL. Webform (LoadCtl.aspx) also passes a...
3
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
1
by: Demetri | last post by:
I'm trying to determine if we want to use panels or user controls for our pages. Our primary concern is performance, page loading and posting speed. To illustrate my question, lets use the...
5
by: c676228 | last post by:
Hi, I guess I am confused. In aspx script, I mean (you won't use Codebehind="enrollinfo.aspx.vb", but mix code with html and code together) You can access user control's property directly. Since I...
2
by: Scott | last post by:
I'm using a master page (mp_TableMaint.aspx) with one Content area (ID: Content1). Content1 contains several usercontrols, which are hidden. The goal is to show the correct control based on the...
4
by: tshad | last post by:
Is there a way for a User Control to access an object (such as label or textbox) on the .aspx page that calls it? For example: x.aspx ************************************** .... Sub...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.