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

accessing User Controls - URGENT please help!

Hi all,

I've got a page with a user control on, added via VS. I'm trying to get to a
property of the user control (or more precisely, a public var).

Here's the code at the top of my aspx page...

<%@ Register TagPrefix="dI2" TagName="dartsUC_rolodexsearch"
Src="dartsUC_rolodexsearch.ascx" %>

then in the html...

<dI2:dartsUC_rolodexsearch id="dartsUC_rolodexsearch1"
runat="server"></dI2:dartsUC_rolodexsearch>

and the top of the ascx file looks like...

<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="dartsUC_rolodexsearch.ascx.cs"
Inherits="dartsIntranet.WUC_rolodexsearch"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>

My question is how do I get to the user control. If I try

protected dartsUC_rolodexsearch dartsUC_rolodexsearch1;

in my page cs file, I get a cannot find type or namespace
"dartsUC_rolodexsearch".

Please, please help. I've been stuck on this for 2wks now - can't find
anything that makes sense!

Cheers
Dan
Nov 18 '05 #1
5 1488
Hi,

It is mentioned as in ascx file, the Inherits property is,

Inherits="dartsIntranet.WUC_rolodexsearch"

It means that, ur namespace is "dartsIntranet" and your class name is
"WUC_rolodexsearch".

So, if u like to use ur usercontrol in one of the aspx pages, create an
instance of ur usercontrol class and not the one that is given in the Tag
Prefix.

so the actual code be,

protected WUC_rolodexsearch dartsUC_rolodexsearch1;

Regards,
Kamal T.

"Dan Nash" wrote:
Hi all,

I've got a page with a user control on, added via VS. I'm trying to get to a
property of the user control (or more precisely, a public var).

Here's the code at the top of my aspx page...

<%@ Register TagPrefix="dI2" TagName="dartsUC_rolodexsearch"
Src="dartsUC_rolodexsearch.ascx" %>

then in the html...

<dI2:dartsUC_rolodexsearch id="dartsUC_rolodexsearch1"
runat="server"></dI2:dartsUC_rolodexsearch>

and the top of the ascx file looks like...

<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="dartsUC_rolodexsearch.ascx.cs"
Inherits="dartsIntranet.WUC_rolodexsearch"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>

My question is how do I get to the user control. If I try

protected dartsUC_rolodexsearch dartsUC_rolodexsearch1;

in my page cs file, I get a cannot find type or namespace
"dartsUC_rolodexsearch".

Please, please help. I've been stuck on this for 2wks now - can't find
anything that makes sense!

Cheers
Dan

Nov 18 '05 #2
Kamal,

Thanks, that'sworked. Sort of. I still cant get access to my variable though.

I added the line you suggested. I also added a label to my page.

Now, the final line in my control is rolodexSQL = "SELECT * FROM ContactsDB";

so, in my aspx page, I'm doing

lblSql.Text = dartsUC_rolodexsearch1.rolodexSQL;

The rolodexSQL part popped up in the drop down list, so that was nice.
However, when I run the program, I get nothing in my label control. Almost
like rolodexSQL is returning "" or null. If I add .ToString() to the line, i
get a "object reference not set to an instance of an object" error.

Any ideas much appreciated :o)

Cheers
Dan

"Kamal T." wrote:
Hi,

It is mentioned as in ascx file, the Inherits property is,

Inherits="dartsIntranet.WUC_rolodexsearch"

It means that, ur namespace is "dartsIntranet" and your class name is
"WUC_rolodexsearch".

So, if u like to use ur usercontrol in one of the aspx pages, create an
instance of ur usercontrol class and not the one that is given in the Tag
Prefix.

so the actual code be,

protected WUC_rolodexsearch dartsUC_rolodexsearch1;

Regards,
Kamal T.

"Dan Nash" wrote:
Hi all,

I've got a page with a user control on, added via VS. I'm trying to get to a
property of the user control (or more precisely, a public var).

Here's the code at the top of my aspx page...

<%@ Register TagPrefix="dI2" TagName="dartsUC_rolodexsearch"
Src="dartsUC_rolodexsearch.ascx" %>

then in the html...

<dI2:dartsUC_rolodexsearch id="dartsUC_rolodexsearch1"
runat="server"></dI2:dartsUC_rolodexsearch>

and the top of the ascx file looks like...

<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="dartsUC_rolodexsearch.ascx.cs"
Inherits="dartsIntranet.WUC_rolodexsearch"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>

My question is how do I get to the user control. If I try

protected dartsUC_rolodexsearch dartsUC_rolodexsearch1;

in my page cs file, I get a cannot find type or namespace
"dartsUC_rolodexsearch".

Please, please help. I've been stuck on this for 2wks now - can't find
anything that makes sense!

Cheers
Dan

Nov 18 '05 #3
Hi,

Write a public property in ur control to expose the value of "rolodexSQL",
and use the public propertty to get the value in ur aspx page.

For eg:

write a peroperty,

public string GetRolodexSQLValue
{
get
{
return rolodexSQL;
}
}

In ur aspx page,

lblSql.Text = dartsUC_rolodexsearch1.GetRolodexSQLValue;

Hope this shld. help u out....

Regards,
Kamal T.

"Dan Nash" wrote:
Kamal,

Thanks, that'sworked. Sort of. I still cant get access to my variable though.

I added the line you suggested. I also added a label to my page.

Now, the final line in my control is rolodexSQL = "SELECT * FROM ContactsDB";

so, in my aspx page, I'm doing

lblSql.Text = dartsUC_rolodexsearch1.rolodexSQL;

The rolodexSQL part popped up in the drop down list, so that was nice.
However, when I run the program, I get nothing in my label control. Almost
like rolodexSQL is returning "" or null. If I add .ToString() to the line, i
get a "object reference not set to an instance of an object" error.

Any ideas much appreciated :o)

Cheers
Dan

"Kamal T." wrote:
Hi,

It is mentioned as in ascx file, the Inherits property is,

Inherits="dartsIntranet.WUC_rolodexsearch"

It means that, ur namespace is "dartsIntranet" and your class name is
"WUC_rolodexsearch".

So, if u like to use ur usercontrol in one of the aspx pages, create an
instance of ur usercontrol class and not the one that is given in the Tag
Prefix.

so the actual code be,

protected WUC_rolodexsearch dartsUC_rolodexsearch1;

Regards,
Kamal T.

"Dan Nash" wrote:
Hi all,

I've got a page with a user control on, added via VS. I'm trying to get to a
property of the user control (or more precisely, a public var).

Here's the code at the top of my aspx page...

<%@ Register TagPrefix="dI2" TagName="dartsUC_rolodexsearch"
Src="dartsUC_rolodexsearch.ascx" %>

then in the html...

<dI2:dartsUC_rolodexsearch id="dartsUC_rolodexsearch1"
runat="server"></dI2:dartsUC_rolodexsearch>

and the top of the ascx file looks like...

<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="dartsUC_rolodexsearch.ascx.cs"
Inherits="dartsIntranet.WUC_rolodexsearch"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>

My question is how do I get to the user control. If I try

protected dartsUC_rolodexsearch dartsUC_rolodexsearch1;

in my page cs file, I get a cannot find type or namespace
"dartsUC_rolodexsearch".

Please, please help. I've been stuck on this for 2wks now - can't find
anything that makes sense!

Cheers
Dan

Nov 18 '05 #4
Kamal,

Thanks, that looks better, however it's still not working. I wrote the
property as so...

private string rolodexSQL;
public string GetRolodexSQLValue
{
get
{
return rolodexSQL != null ? rolodexSQL : "NA";
}
}

and then in Page_Load of the control..

rolodexSQL = "test";

then, as the last line in my aspx page_load...

PageTitle.InnerHTML = dartsUC_rolodexsearch1.GetRolodexSQLValue;

where PageTitle is the id of the <title> element with a protected var
attached.

Compiles and runs fine, but I always get NA in the title bar. It's like my
statement

rolodexSQL = "test"; statement is being ignored completely.

:(

Thanks for your help
Dan

"Kamal T." wrote:
Hi,

Write a public property in ur control to expose the value of "rolodexSQL",
and use the public propertty to get the value in ur aspx page.

For eg:

write a peroperty,

public string GetRolodexSQLValue
{
get
{
return rolodexSQL;
}
}

In ur aspx page,

lblSql.Text = dartsUC_rolodexsearch1.GetRolodexSQLValue;

Hope this shld. help u out....

Regards,
Kamal T.

"Dan Nash" wrote:
Kamal,

Thanks, that'sworked. Sort of. I still cant get access to my variable though.

I added the line you suggested. I also added a label to my page.

Now, the final line in my control is rolodexSQL = "SELECT * FROM ContactsDB";

so, in my aspx page, I'm doing

lblSql.Text = dartsUC_rolodexsearch1.rolodexSQL;

The rolodexSQL part popped up in the drop down list, so that was nice.
However, when I run the program, I get nothing in my label control. Almost
like rolodexSQL is returning "" or null. If I add .ToString() to the line, i
get a "object reference not set to an instance of an object" error.

Any ideas much appreciated :o)

Cheers
Dan

"Kamal T." wrote:
Hi,

It is mentioned as in ascx file, the Inherits property is,

Inherits="dartsIntranet.WUC_rolodexsearch"

It means that, ur namespace is "dartsIntranet" and your class name is
"WUC_rolodexsearch".

So, if u like to use ur usercontrol in one of the aspx pages, create an
instance of ur usercontrol class and not the one that is given in the Tag
Prefix.

so the actual code be,

protected WUC_rolodexsearch dartsUC_rolodexsearch1;

Regards,
Kamal T.

"Dan Nash" wrote:

> Hi all,
>
> I've got a page with a user control on, added via VS. I'm trying to get to a
> property of the user control (or more precisely, a public var).
>
> Here's the code at the top of my aspx page...
>
> <%@ Register TagPrefix="dI2" TagName="dartsUC_rolodexsearch"
> Src="dartsUC_rolodexsearch.ascx" %>
>
> then in the html...
>
> <dI2:dartsUC_rolodexsearch id="dartsUC_rolodexsearch1"
> runat="server"></dI2:dartsUC_rolodexsearch>
>
> and the top of the ascx file looks like...
>
> <%@ Control Language="c#" AutoEventWireup="false"
> Codebehind="dartsUC_rolodexsearch.ascx.cs"
> Inherits="dartsIntranet.WUC_rolodexsearch"
> TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
>
> My question is how do I get to the user control. If I try
>
> protected dartsUC_rolodexsearch dartsUC_rolodexsearch1;
>
> in my page cs file, I get a cannot find type or namespace
> "dartsUC_rolodexsearch".
>
> Please, please help. I've been stuck on this for 2wks now - can't find
> anything that makes sense!
>
> Cheers
>
>
> Dan

Nov 18 '05 #5
Hi peeps

Further to the earlier post, I've done some more investigating.

It seems that, although I cannot get to the variable from the user control,
I can infact get to it in the aspx page with the following statement...

<%= dartsUC_rolodexsearch1.GetRolodexSQLValue %>

Any ideas why this works and yet I can't get to the UC variable in
code-behind, which is where I actually need it.

Cheers
Dan

"Dan Nash" wrote:
Kamal,

Thanks, that looks better, however it's still not working. I wrote the
property as so...

private string rolodexSQL;
public string GetRolodexSQLValue
{
get
{
return rolodexSQL != null ? rolodexSQL : "NA";
}
}

and then in Page_Load of the control..

rolodexSQL = "test";

then, as the last line in my aspx page_load...

PageTitle.InnerHTML = dartsUC_rolodexsearch1.GetRolodexSQLValue;

where PageTitle is the id of the <title> element with a protected var
attached.

Compiles and runs fine, but I always get NA in the title bar. It's like my
statement

rolodexSQL = "test"; statement is being ignored completely.

:(

Thanks for your help
Dan

"Kamal T." wrote:
Hi,

Write a public property in ur control to expose the value of "rolodexSQL",
and use the public propertty to get the value in ur aspx page.

For eg:

write a peroperty,

public string GetRolodexSQLValue
{
get
{
return rolodexSQL;
}
}

In ur aspx page,

lblSql.Text = dartsUC_rolodexsearch1.GetRolodexSQLValue;

Hope this shld. help u out....

Regards,
Kamal T.

"Dan Nash" wrote:
Kamal,

Thanks, that'sworked. Sort of. I still cant get access to my variable though.

I added the line you suggested. I also added a label to my page.

Now, the final line in my control is rolodexSQL = "SELECT * FROM ContactsDB";

so, in my aspx page, I'm doing

lblSql.Text = dartsUC_rolodexsearch1.rolodexSQL;

The rolodexSQL part popped up in the drop down list, so that was nice.
However, when I run the program, I get nothing in my label control. Almost
like rolodexSQL is returning "" or null. If I add .ToString() to the line, i
get a "object reference not set to an instance of an object" error.

Any ideas much appreciated :o)

Cheers
Dan

"Kamal T." wrote:

> Hi,
>
> It is mentioned as in ascx file, the Inherits property is,
>
> Inherits="dartsIntranet.WUC_rolodexsearch"
>
> It means that, ur namespace is "dartsIntranet" and your class name is
> "WUC_rolodexsearch".
>
> So, if u like to use ur usercontrol in one of the aspx pages, create an
> instance of ur usercontrol class and not the one that is given in the Tag
> Prefix.
>
> so the actual code be,
>
> protected WUC_rolodexsearch dartsUC_rolodexsearch1;
>
> Regards,
> Kamal T.
>
> "Dan Nash" wrote:
>
> > Hi all,
> >
> > I've got a page with a user control on, added via VS. I'm trying to get to a
> > property of the user control (or more precisely, a public var).
> >
> > Here's the code at the top of my aspx page...
> >
> > <%@ Register TagPrefix="dI2" TagName="dartsUC_rolodexsearch"
> > Src="dartsUC_rolodexsearch.ascx" %>
> >
> > then in the html...
> >
> > <dI2:dartsUC_rolodexsearch id="dartsUC_rolodexsearch1"
> > runat="server"></dI2:dartsUC_rolodexsearch>
> >
> > and the top of the ascx file looks like...
> >
> > <%@ Control Language="c#" AutoEventWireup="false"
> > Codebehind="dartsUC_rolodexsearch.ascx.cs"
> > Inherits="dartsIntranet.WUC_rolodexsearch"
> > TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
> >
> > My question is how do I get to the user control. If I try
> >
> > protected dartsUC_rolodexsearch dartsUC_rolodexsearch1;
> >
> > in my page cs file, I get a cannot find type or namespace
> > "dartsUC_rolodexsearch".
> >
> > Please, please help. I've been stuck on this for 2wks now - can't find
> > anything that makes sense!
> >
> > Cheers
> >
> >
> > Dan

Nov 18 '05 #6

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

Similar topics

4
by: John | last post by:
Hi all, I have posted this type of question quite a few times but to date, no-one has actually been able to provide me with a solution. I really need to understand how to do this properly. My...
3
by: Philip Poole | last post by:
Hello everyone, Please help with this as it is driving me up the wall and it is urgent i finish this page, this is the first time I have used User Controls and I think I must have completly...
2
by: Gerhard | last post by:
I have a .net application that I want to run in a DMZ, with the SQL Server and file system behind another firewall. Is there a secure way to get to files from my application, or would it be better...
0
by: khalid sohail | last post by:
hi can any1 help me in accessing controls that exist in datagrid using the javascript.......ordinary that controls are access by the document.getelementById('controlid') mathod but that does not...
9
by: J055 | last post by:
Hi I have a standard asp page which uses a MasterPage. The MasterPage contains a User control. How can I access a public method in the User control from my WebForm page? I can't move the method...
15
by: Ofer Zelig | last post by:
I'll describe the simplest situation of the problem. I have a simple Web User Control which only contains a: <div id="bla" runat="server" /. I dynamically add it to a page, by performing: ...
4
by: Frank Rizzo | last post by:
Hello, I know that it's a bad thing to update UI components on a background thread. But is it fairly safe to access them? I want to iterate through a tree list. Thanks.
8
by: GaryDean | last post by:
I have a Wizard page and need to affect the next and previous buttons from my code-behind. I've googled around and found two solutions, and neither appear to work. I can access the SideBarList...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
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: 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: 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
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
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
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
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,...

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.