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

Using a user control within a master page

When you set the value of a user control in a master page, do you have to
reference it differently? Also, do they have to be given different names in
the templates?

For example, this is what I have....
(uc1 is a user control I defined)

MasterPage.master
-- FormView#FormView1
--<EditItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"
--<ItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"
--<InsertItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"

Note that all the user controls have the same name.

In my code, when I switch modes in my formview I am trying to call a
function SetTime in my uc. It seems to work because I check the value
before & after. But it doesn't visually appear on the screen. Here's the
different ways I have tried...

1. CType(FormView1.FindControl("ucTime1"),
common_ucTimeSelect).SetTime(MyTime)
2.
CType(FormView1.Controls(0).Controls(1).Controls(0 ).FindControl("ucTime1"),
common_ucTimeSelect).SetTime(MyTime)

I check the value of the user control and the time IS set correctly, but
it's doesn't appear set on the screen.

Can you help me out?

Thanks!
Jun 27 '08 #1
3 1432
To add a web user control to a master page, you must register the control

<%@ Register TagPrefix="uc1" TagName="ucTimeSelect" Src="~/ucTimeSelect.ascx" %>
-- FormView#FormView1
--<EditItemTemplate>
--<table><tr><td>
<uic1:ucTimeSelect id="ucTime1" runat="server" />

etc...

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cirene" <ci****@nowhere.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
When you set the value of a user control in a master page, do you have to reference it differently? Also, do they
have to be given different names in the templates?

For example, this is what I have....
(uc1 is a user control I defined)

MasterPage.master
-- FormView#FormView1
--<EditItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"
--<ItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"
--<InsertItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"

Note that all the user controls have the same name.

In my code, when I switch modes in my formview I am trying to call a function SetTime in my uc. It seems to work
because I check the value before & after. But it doesn't visually appear on the screen. Here's the different ways I
have tried...

1. CType(FormView1.FindControl("ucTime1"), common_ucTimeSelect).SetTime(MyTime)
2. CType(FormView1.Controls(0).Controls(1).Controls(0 ).FindControl("ucTime1"), common_ucTimeSelect).SetTime(MyTime)

I check the value of the user control and the time IS set correctly, but it's doesn't appear set on the screen.

Can you help me out?

Thanks!

Jun 27 '08 #2
To follow up on Juan's post, the reason user controls are tricky in a master
page is the master page is, underneath the hood, a user control. I know it
does not feel this way when you design with it, but it is.

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

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
"Cirene" <ci****@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
When you set the value of a user control in a master page, do you have to
reference it differently? Also, do they have to be given different names
in the templates?

For example, this is what I have....
(uc1 is a user control I defined)

MasterPage.master
-- FormView#FormView1
--<EditItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"
--<ItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"
--<InsertItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"

Note that all the user controls have the same name.

In my code, when I switch modes in my formview I am trying to call a
function SetTime in my uc. It seems to work because I check the value
before & after. But it doesn't visually appear on the screen. Here's the
different ways I have tried...

1. CType(FormView1.FindControl("ucTime1"),
common_ucTimeSelect).SetTime(MyTime)
2.
CType(FormView1.Controls(0).Controls(1).Controls(0 ).FindControl("ucTime1"),
common_ucTimeSelect).SetTime(MyTime)

I check the value of the user control and the time IS set correctly, but
it's doesn't appear set on the screen.

Can you help me out?

Thanks!
Jun 27 '08 #3
I didn't want to add the uc to a master page. I wanted to add it to a page
that is based on the master page.

And, I did add the register at the top of the page already. :)

It shows up fine. It's just that when some values are set (via code) it
looks like it took (when debugging) but when the page shows up it doesn't
reflect the changes.

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:e1**************@TK2MSFTNGP03.phx.gbl...
To add a web user control to a master page, you must register the control

<%@ Register TagPrefix="uc1" TagName="ucTimeSelect"
Src="~/ucTimeSelect.ascx" %>
-- FormView#FormView1
--<EditItemTemplate>
--<table><tr><td>
<uic1:ucTimeSelect id="ucTime1" runat="server" />

etc...

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cirene" <ci****@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>When you set the value of a user control in a master page, do you have to
reference it differently? Also, do they have to be given different names
in the templates?

For example, this is what I have....
(uc1 is a user control I defined)

MasterPage.master
-- FormView#FormView1
--<EditItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"
--<ItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"
--<InsertItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"

Note that all the user controls have the same name.

In my code, when I switch modes in my formview I am trying to call a
function SetTime in my uc. It seems to work because I check the value
before & after. But it doesn't visually appear on the screen. Here's
the different ways I have tried...

1. CType(FormView1.FindControl("ucTime1"),
common_ucTimeSelect).SetTime(MyTime)
2.
CType(FormView1.Controls(0).Controls(1).Controls( 0).FindControl("ucTime1"),
common_ucTimeSelect).SetTime(MyTime)

I check the value of the user control and the time IS set correctly, but
it's doesn't appear set on the screen.

Can you help me out?

Thanks!


Jun 27 '08 #4

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

Similar topics

10
by: George G. | last post by:
Hi there, I am busy writing a new asp.net application and I am reusing some of my existing asp functions and methods in a user control. I need access to session, request and response in some of...
20
by: Alan Silver | last post by:
Hello, In classic ASP, I used to use two include files on each page, one before and one after the main content, to provide a consistent layout across a web site. That way I could just change the...
1
by: Friso Wiskerke | last post by:
Hi All, We've got an VS.2003 ASPNET (VB) webproject which we would like to convert to VS.2005 so that we can make use of the Master Page feature. Converting the initial pages to 2005 is not such...
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...
2
by: Paras | last post by:
Hi, I have 3 ContentPlaceHolders in the MasterPage. In the 2nd content I have placed a usercontrol which has anchor link. This loads another page (without changing loading the content of...
1
by: schneider | last post by:
Is it possible to get access to the local resource (App_LocalResources) of an aspx page from within a user control located somewhere else? I have created a user control which I want to add to a...
3
by: Mick Walker | last post by:
Hi All, I have a user control on my master page, which exposes 3 public properties (all boolean). Basically by the values of these properties, the user control builds a menu to for users to...
5
by: Dinu | last post by:
How to Cast a Variable to User control in ASP.NET using vb.net as code- behind
10
by: =?Utf-8?B?RGFuaQ==?= | last post by:
Hi, Trying to create a master page that holds a menu, and the menu switches between pages in the site. 2 problem arrosed: a. When I navigate from page to page (all AJAX Web Forms, with the...
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: 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...
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?
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
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...

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.