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

HTML Controls and User controls

I have a user control that is basically a login dialogue.
If I add the user control to webpage1, can I access the
properties directly from C# codebehind, or do I have to
access the properties from HTML behind webpage1.

Thanks in advance. Pete
Nov 17 '05 #1
6 2329
Webpage1 is a standard ASP.NET webform which contains the
user control. I know I can access properties of the user
control via the HTML of webpage1 i.e.
<uc1:LoginUserControl id="LoginUserControl1"
property1="Hello" property2="Goodbye"
runat="server"></uc1:LoginUserControl>

but is it possible to access the properties from webpage1
code behind page.

Hope this is a little clearer.
Pete.
-----Original Message-----
What exactly is "webpage1?"

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Big things are made up of
lots of Little things.

"trinitypete" <su*****@trinity.com> wrote in message
news:0a****************************@phx.gbl...
I have a user control that is basically a login dialogue. If I add the user control to webpage1, can I access the
properties directly from C# codebehind, or do I have to
access the properties from HTML behind webpage1.

Thanks in advance. Pete

.

Nov 17 '05 #2
Yes It is possible. Here is the code to do it.

Dim _myControl As Control = Page.FindControl("UserControlName")
Dim _myControlType As Type = _myControl.GetType()
Dim _myControl_Property As PropertyInfo =
_myControlType.GetProperty("PROPERTYNAME")

sTemp = _myControl_Property.GetValue(_myControl, Nothing)
Hope this helps.

Ryan
"trinitypete" <su*****@trinity.com> wrote in message
news:0c****************************@phx.gbl...
Webpage1 is a standard ASP.NET webform which contains the
user control. I know I can access properties of the user
control via the HTML of webpage1 i.e.
<uc1:LoginUserControl id="LoginUserControl1"
property1="Hello" property2="Goodbye"
runat="server"></uc1:LoginUserControl>

but is it possible to access the properties from webpage1
code behind page.

Hope this is a little clearer.
Pete.
-----Original Message-----
What exactly is "webpage1?"

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Big things are made up of
lots of Little things.

"trinitypete" <su*****@trinity.com> wrote in message
news:0a****************************@phx.gbl...
I have a user control that is basically a login dialogue. If I add the user control to webpage1, can I access the
properties directly from C# codebehind, or do I have to
access the properties from HTML behind webpage1.

Thanks in advance. Pete

.

Nov 17 '05 #3
It worked a treat - Thanks.
-----Original Message-----
Yes It is possible. Here is the code to do it.

Dim _myControl As Control = Page.FindControl ("UserControlName") Dim _myControlType As Type = _myControl.GetType() Dim _myControl_Property As PropertyInfo =
_myControlType.GetProperty("PROPERTYNAME")

sTemp = _myControl_Property.GetValue (_myControl, Nothing)

Hope this helps.

Ryan
"trinitypete" <su*****@trinity.com> wrote in message
news:0c****************************@phx.gbl...
Webpage1 is a standard ASP.NET webform which contains the user control. I know I can access properties of the user
control via the HTML of webpage1 i.e.
<uc1:LoginUserControl id="LoginUserControl1"
property1="Hello" property2="Goodbye"
runat="server"></uc1:LoginUserControl>

but is it possible to access the properties from webpage1 code behind page.

Hope this is a little clearer.
Pete.
>-----Original Message-----
>What exactly is "webpage1?"
>
>HTH,
>
>Kevin Spencer
>Microsoft FrontPage MVP
>Internet Developer
>http://www.takempis.com
>Big things are made up of
>lots of Little things.
>
>"trinitypete" <su*****@trinity.com> wrote in message
>news:0a****************************@phx.gbl...
>> I have a user control that is basically a login

dialogue.
>> If I add the user control to webpage1, can I access the >> properties directly from C# codebehind, or do I have to >> access the properties from HTML behind webpage1.
>>
>> Thanks in advance. Pete
>
>
>.
>

.

Nov 17 '05 #4
Your CodeBehind Page should have a reference to the control if you used the
tag you mentioned in your reply. You can therefore access the properties of
the object in your CodeBehind (using its' ID) without any problem.

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Big things are made up of
lots of Little things.

"trinitypete" <su*****@trinity.com> wrote in message
news:0c****************************@phx.gbl...
Webpage1 is a standard ASP.NET webform which contains the
user control. I know I can access properties of the user
control via the HTML of webpage1 i.e.
<uc1:LoginUserControl id="LoginUserControl1"
property1="Hello" property2="Goodbye"
runat="server"></uc1:LoginUserControl>

but is it possible to access the properties from webpage1
code behind page.

Hope this is a little clearer.
Pete.
-----Original Message-----
What exactly is "webpage1?"

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Big things are made up of
lots of Little things.

"trinitypete" <su*****@trinity.com> wrote in message
news:0a****************************@phx.gbl...
I have a user control that is basically a login dialogue. If I add the user control to webpage1, can I access the
properties directly from C# codebehind, or do I have to
access the properties from HTML behind webpage1.

Thanks in advance. Pete

.

Nov 17 '05 #5
Sorry trinitypete,

I misunderstood your question, and neglected to observe that you were
talking about a User Control instead of a Server Control. Handling the User
Control from your CodeBehind is a bit trickier than a Server Control. The
following MSDN article should help:

http://msdn.microsoft.com/library/de...properties.asp

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Big things are made up of
lots of Little things.

"trinitypete" <su*****@trinity.com> wrote in message
news:01****************************@phx.gbl...
Kevin,

Now I am intrigued. The HTML used in the webpage1 has the
tags etc as follows:

<%@ Register TagPrefix="uc1" TagName="LoginUserControl"
Src="LoginUserControl.ascx" %>
<uc1:LoginUserControl id="LoginUserControl1"
runat="server"></uc1:LoginUserControl>

I tried to access the control using LoginUserControl1 but
intellisense didn't pick it up. I cant find any references
to the control in webpage1 code behind? Does the Tagprefix
come into it at all - ie is it a namespace issue?

I have tried recreating the project from scratch but there
is still no reference in webpage1 code behind?
-----Original Message-----
Your CodeBehind Page should have a reference to the

control if you used the
tag you mentioned in your reply. You can therefore access

the properties of
the object in your CodeBehind (using its' ID) without any

problem.

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Big things are made up of
lots of Little things.

"trinitypete" <su*****@trinity.com> wrote in message
news:0c****************************@phx.gbl...
Webpage1 is a standard ASP.NET webform which contains the user control. I know I can access properties of the user
control via the HTML of webpage1 i.e.
<uc1:LoginUserControl id="LoginUserControl1"
property1="Hello" property2="Goodbye"
runat="server"></uc1:LoginUserControl>

but is it possible to access the properties from webpage1 code behind page.

Hope this is a little clearer.
Pete.

>-----Original Message-----
>What exactly is "webpage1?"
>
>HTH,
>
>Kevin Spencer
>Microsoft FrontPage MVP
>Internet Developer
>http://www.takempis.com
>Big things are made up of
>lots of Little things.
>
>"trinitypete" <su*****@trinity.com> wrote in message
>news:0a****************************@phx.gbl...
>> I have a user control that is basically a login
dialogue.
>> If I add the user control to webpage1, can I access the >> properties directly from C# codebehind, or do I have to >> access the properties from HTML behind webpage1.
>>
>> Thanks in advance. Pete
>
>
>.
>

.

Nov 17 '05 #6
Thanks Kevin,

Will research link.
-----Original Message-----
Sorry trinitypete,

I misunderstood your question, and neglected to observe that you weretalking about a User Control instead of a Server Control. Handling the UserControl from your CodeBehind is a bit trickier than a Server Control. Thefollowing MSDN article should help:

http://msdn.microsoft.com/library/default.asp? url=/library/en-
us/cpguide/html/cpconexposingpageletproperties.asp
HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Big things are made up of
lots of Little things.

"trinitypete" <su*****@trinity.com> wrote in message
news:01****************************@phx.gbl...
Kevin,

Now I am intrigued. The HTML used in the webpage1 has the tags etc as follows:

<%@ Register TagPrefix="uc1" TagName="LoginUserControl"
Src="LoginUserControl.ascx" %>
<uc1:LoginUserControl id="LoginUserControl1"
runat="server"></uc1:LoginUserControl>

I tried to access the control using LoginUserControl1 but intellisense didn't pick it up. I cant find any references to the control in webpage1 code behind? Does the Tagprefix come into it at all - ie is it a namespace issue?

I have tried recreating the project from scratch but there is still no reference in webpage1 code behind?
>-----Original Message-----
>Your CodeBehind Page should have a reference to the

control if you used the
>tag you mentioned in your reply. You can therefore access
the properties of
>the object in your CodeBehind (using its' ID) without
any problem.
>
>HTH,
>
>Kevin Spencer
>Microsoft FrontPage MVP
>Internet Developer
>http://www.takempis.com
>Big things are made up of
>lots of Little things.
>
>"trinitypete" <su*****@trinity.com> wrote in message
>news:0c****************************@phx.gbl...
>> Webpage1 is a standard ASP.NET webform which contains

the
>> user control. I know I can access properties of the
user >> control via the HTML of webpage1 i.e.
>> <uc1:LoginUserControl id="LoginUserControl1"
>> property1="Hello" property2="Goodbye"
>> runat="server"></uc1:LoginUserControl>
>>
>> but is it possible to access the properties from

webpage1
>> code behind page.
>>
>> Hope this is a little clearer.
>> Pete.
>>
>> >-----Original Message-----
>> >What exactly is "webpage1?"
>> >
>> >HTH,
>> >
>> >Kevin Spencer
>> >Microsoft FrontPage MVP
>> >Internet Developer
>> >http://www.takempis.com
>> >Big things are made up of
>> >lots of Little things.
>> >
>> >"trinitypete" <su*****@trinity.com> wrote in message
>> >news:0a****************************@phx.gbl...
>> >> I have a user control that is basically a login
>> dialogue.
>> >> If I add the user control to webpage1, can I

access the
>> >> properties directly from C# codebehind, or do I
have to
>> >> access the properties from HTML behind webpage1.
>> >>
>> >> Thanks in advance. Pete
>> >
>> >
>> >.
>> >
>
>
>.
>

.

Nov 17 '05 #7

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

Similar topics

5
by: Richard Cornford | last post by:
I am interested in hearing opinions on the semantic meaning of FORM (elements) in HTML. I have to start of apologising because this question arose in a context that is not applicable to the...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
3
by: Chris Kennedy | last post by:
I am fine designing .net apps by myself. For my company to start utilising ..net properly we need systems and approaches in place where we can integrate web designers designing the frontend and web...
4
by: Zuel | last post by:
Hi Folks. So I have a small problem. My DoPostBack function is not writen to the HTML page nor are the asp:buttons calling the DoPostBack. My Goal is to create a totaly dynamic web page where...
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
5
by: Brian Kitt | last post by:
I have a C# application that builds dynamic HTML and renders it. Because it is rendered in this way, the input controls are not server controls. I write the entire page, which has a variable...
1
by: E. Tom Jorgenson | last post by:
I've run into a problem on a couple of projects that I think I've identified - but would like confirmation of what I think is going on. Also interested in any fast solutions to fix the user...
2
by: Ben Amada | last post by:
Hello, A partner is going to be creating some HTML files that I plan on converting to user controls (UC) and dynamically load at runtime. I'm guessing Visual Studio doesn't come with some...
2
by: robert112 | last post by:
This is quite a hard one guys. ***Some necessary back ground Info*** I have an asp.net 1.1 application that uses a WYSIWYG to return some html created by the user in the admin section of the...
19
by: ThatsIT.net.au | last post by:
I come from a classic asp background, but have started using ASP.NET about 12 months ago, but I'm still not sure about the pros and cons of using controls v HTML spat out from code as you would in...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.